背景:
qt官网只提供x86和x64的qt安装包,别的架构平台只能自己编译qt源码
首先在网上搜索QT镜像下载:
我是在清华大学网址里面下载的qt-everywhere-src-5.15.0.tar.xz,注意下载tar.xz就好,不要下载zip版本的,步骤:进入网址->archive/->qt/5.15/5.15.0/->single/qt-everywhere-src-5.15.0.tar.xz(相当快哈哈哈)
接着安装基础编译环境:
sudo apt-get install libxcb-xinerama0-dev
sudo apt-get install build-essential perl python git
sudo apt-get install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
sudo apt-get install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
sudo apt-get install flex bison gperf libicu-dev libxslt-dev ruby
sudo apt-get install libssl-dev libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libdbus-1-dev libfontconfig1-dev libcap-dev libxtst-dev libpulse-dev libudev-dev libpci-dev libnss3-dev libasound2-dev libxss-dev libegl1-mesa-dev gperf bison
sudo apt-get install libasound2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
sudo apt install libclang-6.0-dev llvm-6.0
sudo apt-get insatll clang-8(要不要都行)
#安装ninja编译依赖re2c
sudo apt-get insatll re2c
#编译ninja
cd qt-everywhere-src-5.15.0/qtwebengine/src/3rdparty/ninja
./configure.py --bootstrap
#安装ninja
sudo cp ./ninja /usr/bin
#检查安装是否完成
ninja --version
注意:其中有些库是因为版本更新的原因,名字也换了,不过可以打出前面的用tab补全,一定要把库都装上,不然以后遇到什么问题不好说。
1、在下载QT源码解压后配置config:
./configure -prefix /usr/local/Qt-5.15.0 -release -opensource -nomake examples -nomake tests -confirm-license -shared -no-pkg-config -no-iconv -xcb -skip qtdeclarative -skip qtwayland
注意:
(1)QT源码解压路径不能有中文
(2)-skip qtdeclarative -skip qtwayland (我跳过这两个模块是因为我在编译和后面make install的时候,这里老是有问题,况且我也用不上这两个模块)
(3)-prefix指定QT安装路径
2、sudo make -j4
注意如果是make的话需要编译3个小时,但是肯定不会出错(亲测),make -j4或者make -j8的话没试过,可能不同电脑不同性能,多核处理器的话说不定出错,这个几率不大。
3、sudo make install
出现以下结果说明安装成功:
注意:5.15.0是我的qt版本
/home/HT706/work/qt-everywhere-src-5.15.0/qt-everywhere-src-5.15.0/qtbase/bin/qmake -install qinstall /home/HT706/work/qt-everywhere-src-5.15.0/qt-everywhere-src-5.15.0/qttranslations/translations/qtxmlpatterns_zh_TW.qm /usr/local/Qt-5.15.0/translations/qtxmlpatterns_zh_TW.qm
make[2]: 离开目录“/home/HT706/work/qt-everywhere-src-5.15.0/qt-everywhere-src-5.15.0/qttranslations/translations”
make[1]: 离开目录“/home/HT706/work/qt-everywhere-src-5.15.0/qt-everywhere-src-5.15.0/qttranslations”
4、配置QT环境变量:
#注意:笔者的qt安装路径为/usr/local/Qt-5.15.0
export QTDIR=/usr/local/Qt-5.15.0
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins/platforms
5、下载qtcreator
命令下载:
sudo apt install qtcreator
6、打开qtcreator配置
1)工具->选项->Qtversion->添加qmake->选择安装路径下bin目录下的qmake
2)工具->选项->构建套件(kit)->手动设置->桌面(默认)->qt版本->选择对应的qt版本(我的是Qt-5.15.0)