CentOS 6/7 install Qt environment (2024)

CentOS 6/7 install Qt environment

  • Basic environment
    • System: 64-bit CentOS 6.10 / CentOS 7.6
    • Qt demand
  • installation steps
    • 1. Install the basic development toolset
    • 2. Install gcc-4.8.2
    • 3. Install python-2.7
    • 4. Install CMake-3.14.4
    • 5. Install gdb
    • 6. Install Qt
    • 7. Other

System: 64-bit CentOS 6.10 / CentOS 7.6

  1. Netease mirror station CentOS-6-x84_64
  2. Netease mirror station CentOS-7-x84_64
  3. Alibaba Cloud Mirror Station CentOS-6-x84_64
  4. Alibaba Cloud Mirror Station CentOS-7-x84_64

Qt demand

  1. Qt-5.7 / Qt5.12
  2. Gcc-4.7 or above
  3. python-2.7
  4. CMake-3 or above
  5. Support for db of python-2.7
  6. Opengl development component
# The following steps are all based on root privileges. # Basic tools include wget, yum, xz, tar, if it is the above system source, there should be, if not, you need to install it yourself. The environment variable is not modified in the # step, by creating a soft link to /usr/bin or /usr/local/bin instead

1. Install the basic development toolset

 yum -y groupinstall Development tools

2. Install gcc-4.8.2

CentOS6.6 upgrades gcc/g++ to version 4.8.2 via yum (the easiest way)
The default gcc version of CentOS-6 is 4.4.7. It does not support c++11, so it needs to be upgraded to version 4.7 or higher. Here, 4.8.2 is selected because it is easy to install. Only.
CentOS-7 defaults to 4.8.5 and can be skipped.

 wget http://people.centos.org/tru/devtools-2/devtools-2.repo mv devtools-2.repo /etc/yum.repos.d yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++ # Make the original program backup mv /usr/bin/gcc /usr/bin/gcc-4.4.7 mv /usr/bin/c++ /usr/bin/c++-4.4.7 mv /usr/bin/g++ /usr/bin/g++-4.4.7 #Create a soft link ln -s /opt/rh/devtoolset-2/root/usr/bin/gcc /usr/bin/gcc ln -s /opt/rh/devtoolset-2/root/usr/bin/c++ /usr/bin/c++ ln -s /opt/rh/devtoolset-2/root/usr/bin/g++ /usr/bin/g++ # View the version number, if 4.8 is displayed, it succeeds gcc --version g++ --version c++ --version

3. Install python-2.7

The default installed python for CentOS-7 is version 2.7.5, which can be skipped here.

 wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tar.xz xz -d Python-2.7.11.tar.xz tar -xvf Python-2.7.11.tar.xz cd Python-2.7.11 ./configure --prefix=/opt/python-2.7.11/ make make install # Don't rename the python2.7 link to python here. # because yum is based on the original version of python, # Modify, you need to point back to yum using python ln -s /opt/python-2.7.11/bin/python2.7 /usr/bin/ # View version number python2.7 --version

4. Install CMake-3.14.4

This version was chosen because this is the latest version.

 wget https://github.com/Kitware/CMake/releases/download/v3.14.4/cmake-3.14.4.tar.gz tar -xvf cmake-3.14.4.tar.gz cd cmake-3.14.4 ./bootstrap --prefix=/opt/cmake-3.14.4/ make make install # If /usr/bin/cmake already exists, make a backup by referring to the part where gcc is installed. ln /opt/cmake-3.14.4/bin/cmake /usr/bin/ # View version number cmake --version

5. Install gdb

CentOS-6/7 has gdb installed by default. Although the version is different, it is not applicable. Because Qt needs to support python's gdb, it needs to be reinstalled. Python is added when installing the configuration. This version of gdb was chosen because this is the latest version, and this version of gdb requires a python version of 2.7+, so there is a second step to install python-2.7.

 wget ftp://sourceware.org/pub/gdb/releases/gdb-8.3.tar.xz xz -d gdb-8.3.tar.xz tar -xvf gdb-8.3.tar cd gdb-8.3 ./configure --prefix=/opt/gdb-8.3/ --with-python='/usr/bin/python2.7' make make install # If /usr/bin/gdb already exists, make a backup by referring to the part where gcc is installed. ln -s /opt/gdb-8.3/bin/gdb /usr/bin/ # View version number gdb --version

6. Install Qt

Qt installation needs to be installed under the visual graphical interface. If there is no GNOME or other X11 interface, it needs to be installed and enabled first.
The Qt version supported by CentOS-6 is from Qt-4 to Qt-5.7. When it is high, the installation will report an error, and the error message will be like the following, but this is meaningless because of the error message. Unable to parse.

Error during installation process (qt.qt5.5123.gcc_64): The output of /opt/Qt/5.12.3/gcc_64/bin/qmake -query is not parseable.

At this time, see the installation details to see what you need el7, and el7 refers to the CentOS-7 environment.
CentOS-7 supports Qt-5.8 or above. The latest stable version is 5.12.3, and 5.13 is still being tested.

Qt versions can go to Qt's download centerhttp://download.qt.io/ Find it yourself, use wget to download it, remember to use it after downloadingchmod a+x Get execute permission.
Qt-5.7.1 Offline installationhttp://download.qt.io/archive/qt/5.7/5.7.1/qt-opensource-linux-x64-5.7.1.run
Qt-5.12.3 Offline Installationhttp://download.qt.io/archive/qt/5.12/5.12.3/qt-opensource-linux-x64-5.12.3.run
Qt-5.12.3 online installation versionhttp://download.qt.io/official_releases/online_installers/qt-unified-linux-x64-online.run
The online installer can be installed with different versions over time. Currently available are 5.12.3 and 5.11.
When installing, it is a graphical interface installation. Remember to select source. This is the source code. Some plugins need to be built when you build them yourself, for example, when using mysql.

7. Other

  1. Install the OpenGL development library

    yum install -y mesa* freeglut*
  2. Install the OpenCV development library

    yum install opencv opencv-devel
  3. Install the mysql development library
    To use mysql in Qt, you need mysql's own library and qtsqlmysql plugin (also known as Qt's mysql driver), you can refer to

    yum install mysql mysql-develcd /opt/Qt5.7.1/5.7/Src/qtbase/src/plugins/sqldrivers/mysql/qmakemake

    Will be generated after makelibqsqlmysql.so, pay attention to the last printed path, mine is here:
    /opt/Qt5.7.1/5.7/Src/qtbase/plugins/sqldrivers/libqsqlmysql.so
    When using, copy the sqldrivers folder to the application directory.

  4. Qt linux program package release
    reference linkPackaged and released qt program under Linux (using linuxdelpoyqt, shell script)
    There is a script in this article:

    #!/bin/shbin=$1 # name desDir="./lib" # if [ ! -d $desDir ];then #echo "makedir $desDir" mkdir $desDirfi libList=$(ldd $bin | awk '{if (match($3,"/")){ printf("%s "),$3 } }')cp $libList $desDir

    Save this script ascopylib.shUsechmod a+x Get execute permission, move to /usr/bin/, and you can call it in the directory where the target program is located. After the call, a directory lib will be created next to the target program. The required libraries are basically available. It is also possible to not use linuxdepoyqt.

CentOS 6/7 install Qt environment (2024)

References

Top Articles
Latest Posts
Article information

Author: Eusebia Nader

Last Updated:

Views: 6006

Rating: 5 / 5 (60 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Eusebia Nader

Birthday: 1994-11-11

Address: Apt. 721 977 Ebert Meadows, Jereville, GA 73618-6603

Phone: +2316203969400

Job: International Farming Consultant

Hobby: Reading, Photography, Shooting, Singing, Magic, Kayaking, Mushroom hunting

Introduction: My name is Eusebia Nader, I am a encouraging, brainy, lively, nice, famous, healthy, clever person who loves writing and wants to share my knowledge and understanding with you.