centos7 编译 Qt5.11.3
默认环境
gcc 4.8.5 20150623
qt 5.9.7
kernel 3.10.0
GNU libc 2.17
更换系统源,在2024年6月30后停止更新维护, 默认源不可用
mv CentOS-Base.repo CentOS-Base.repo.backup
wget -O CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
wget -O epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo
Qt 5.11 支持 gcc7, centos7, ubuntu16
http://www.bim-times.com/qt/Qt-5.11.1/qtdoc/supported-platforms.html#
openSUSE 42.2 (x86_64) GCC 4.8, GCC 7, ICC
Red Hat Enterprise Linux 6.6 (x86_64) GCC 4.9.1 devtoolset-3
Red Hat Enterprise Linux 7.2 (x86_64) GCC 5.3.1 devtoolset-4
Ubuntu 16.04 (x86_64) GCC as provided by Canonical, GCC 6
Linux (x86 and x86_64) GCC 4.8, GCC 4.9, GCC 5, GCC 6, GCC 7
升级gcc (devtoolset)
[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/sclo/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
yum makecache
yum search devtoolset // 7到11
yum install devtoolset-7
scl enable devtoolset-7 bash
编译Qt
qt-everywhere-src-5.11.3.tar.xz
qt-creator-opensource-src-4.8.2.tar.gz
linuxdeployqt-master.tar.gz
;; Qt直接configure编译 -slient可以减少输出
yum install libxcb libxcb-devel xcb-util xcb-util-devel mesa-libGL-devel libxkbcommon-devel
export QT_DIR=/usr/local/Qt-5.11.3
export PATH=$QT_DIR/bin:$PATH
export LD_LIBRARY_PATH=$QT_DIR/lib:$LD_LIBRARY_PATH
;; qt-creator
qmake -r
make
不需要 install, 直接拷贝到 /opt 执行 bin/qtcreator
install 需要指定INSTALL_ROOT目录,不然会安装到根目录
;; 修改 linuxdeployqt源码,不使用appimage和patchelf
yum install patchelf
mkdir build
qmake ..
make
cp bin/linuxdeployqt /usr/bin
参考
[CentOS7 mirror] https://mirrors.tencent.com/help/centos.html
[Centos7下交叉编译QT5.11.1+AArch64架构] https://www.cnblogs.com/jsjrj01/p/18088926
[SCL+Devtoolset 安装与使用笔记] https://cloud.tencent.com/developer/article/1889181
[Building Qt 5 from Git] https://wiki.qt.io/Building_Qt_5_from_Git