How To Install Qt 5.6.3 In Centos 6
Why choose Qt 5.6
Qt 5.6 is a relatively compromised version. Many new features of Qt 5 are already available (such as QWebEngine). Too high versions require manual compilation of GCC, Glibc, Xorg and many other related environments on Centos 6, which is very cumbersome.
Download Qt 5.6
The official download link for Qt5.6 has been removed, and now only long-term support and recent versions can be downloaded from the official.
File Parameters | Parameter Values |
---|---|
File name | qt-opensource-linux-x64-5.6.3.run |
File Size | 680MB |
File Format | Qt Linux Installer |
Download | Github |
Download Tools | No special designation |
Download link | qt-opensource-linux-x64-5.6.3.run |
Install Qt 5.6
-
Give file executable permissions
# chmod 755 qt-opensource-linux-x64-5.6.3.run
-
Run the file to complete the installation
# ./qt-opensource-linux-x64-5.6.3.run
-
Adding environment variables
- create a new
qt5.sh
file:# vim /etc/profile.d/qt5.sh
- Add the following:
export PATH="/opt/Qt5.6.3/5.6.3/gcc_64/bin:$PATH" export PATH="/opt/Qt5.6.3/Tools/QtCreator/bin:$PATH"
:wq
save and exit- Make it effective:
# source /etc/profile
- Check if the settings take effect
# which qmake /opt/Qt5.6.3/5.6.3/gcc_64/bin/qmake
- create a new
Upgrade GCC
-
Why need to upgrade GCC?
Official support documentation from Qt 5.6
https://doc.qt.io/archives/qt-5.6/supported-platforms.html
It can be seen that Qt 5.6 requires at leastGCC 4.9.1
support (many new features cannot be used without upgrading, and some Qt Demo also failed to compile), I choose to installGCC8
here.
-
Install GCC8 with SCL Repo
# yum -y install centos-release-scl # yum -y install devtoolset-8-gcc devtoolset-8-gcc-c++ devtoolset-8-binutils # scl enable devtoolset-8 bash #启动gcc8 # echo "source /opt/rh/devtoolset-8/enable" >>/etc/profile # source /etc/profile
-
Verify the installation
# gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-8/root/usr --mandir=/opt/rh/devtoolset-8/root/usr/share/man --infodir=/opt/rh/devtoolset-8/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-8.3.1-20190311/obj-x86_64-redhat-linux/isl-install --disable-libmpx --with-mpc=/builddir/build/BUILD/gcc-8.3.1-20190311/obj-x86_64-redhat-linux/mpc-install --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC)
Configure qtcreator
-
Tools -> Options -> Build & Run -> Compilers -> Add -> GCC,
Compiler path
points to theg++
path in the Qt installation directory
Tested on Qt 5.6.3
I chose the QWebEngine demo demobrowser
, and we can see that everything compiles and runs properly!