前言
现在网上很多关于qt安装的教程,但是大部分都是直接通过安装包安装,对于ARM64架构的系统,这种方式并不适用。
本文使用的是qt5.14.2和qtcreator4.11.1。
获取Linux系统架构
使用 uname -m
查看系统架构,如下图:
流程
安装编译器–>安装依赖–>编译安装qt–>安装qtcreator
安装编译器
安装依赖
安装依赖参考网站
网站整理:
sudo apt-get install build-essential perl python3 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 flex bison gperf libicu-dev libxslt-dev ruby
sudo apt-get install libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libxtst-dev libxss-dev libdbus-1-dev libevent-dev libfontconfig1-dev libcap-dev libpulse-dev libudev-dev libpci-dev libnss3-dev libasound2-dev libegl1-mesa-dev gperf bison nodejs
sudo apt-get install libasound2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev
sudo apt install clang libclang-dev
编译安装qt
qt不在维护本版
qt在维护版本
注意下载的时候需要下载源代码,解压进行编译。
进去网址后,选择single文件夹
选择tar.xz压缩包
下载后进行解压在opt文件夹中
sudo tar -xvf qt-everywhere-src-5.14.2.tar.xz -C /opt/
解压完成后进入文件夹,并建立auto.sh脚本文件。
sudo mkdir auto.sh
sudo chmod 755 auto.sh
sudo vim auto.sh
#! /bin/bash
./configure -prefix /opt/Qt/ \
-opensource -confirm-license \
-nomake examples \
-nomake tests \
-release \
-skip qt3d \
-skip qtcharts \
-skip qtandroidextras \
-skip qtlocation \
-skip qtmultimedia \
-skip qtsensors \
-skip qtserialbus \
-skip qtserialport \
-skip qtwayland \
-skip qtwebengine \
保存执行脚本文件
sudo ./auto.sh
脚本是为了执行./configure
-prefix /opt/Qt/ \ Qt安装路径
-opensource -confirm-license \ 安装版本,社区版还是商业版
-nomake examples \ 不编译安装例子
-nomake tests \ 不编译安装测试
-release \ release编译
-skip qt3d \ 跳过编译模块
-skip qtcharts \ 跳过编译模块
-skip qtandroidextras \ 跳过编译模块
-skip qtlocation \ 跳过编译模块,此模块容易出错
-skip qtmultimedia \ 跳过编译模块
-skip qtsensors \ 跳过编译模块
-skip qtserialbus \ 跳过编译模块
-skip qtserialport \ 跳过编译模块
-skip qtwayland \ 跳过编译模块
-skip qtwebengine \ 跳过编译模块,此模块容易出错
qtlocation qtwebengine ,如果不是特别需要这两个模块,建议放弃编译
这些命令在解压后的README中有说明
执行后根据提示进行改进,大部分提示错误是依赖安装不全
执行
sudo make -j4
这个执行时间非常长,一般在4-12小时左右,编译内容越多执行时间越长,所以上面放弃编译例子和测试。
完成后执行
sudo make install
此命令会将程序安装在/opt/Qt/ 中。
安装成功后修改环境变量:
sudo vim /etc/profile
export QTDIR=/opt/Qt
export PATH=$QTDIR/bin:$PATH
export MANPATH=$QTDIR/man:$MANPATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
source /etc/profile/
最后执行qmake -v
编译安装qtcreator
安装qtcreator必须先安装Qt,用Qt编译qtcreator,如果编译Qt出错,这个位置编译也会出错。如果Qt编译时,有未编译的模块或者含有不依赖的模块,qt编译不受影响,但是qtcreator会有影响。我试过加-no-opengl \
,编译qt没有错误,安装也可以,编译qtcreator出错。
Qtcreator最好和Qt版本相对应
Qtcreator源码下载
下载完成后解压
这里默认上面教程以完成好以后:
进入解压路径,执行qmaek -r
等待完成后生成MakeFile文件。
然后执行sudo make -j4
等待编译完成后,执行sudo make install
执行完以后文件夹显示内容
打开bin文件夹就会有qtcreator和qtcreator.sh
执行./qtcreator.sh &
这样qtcreator会在后台运行。
最后配置qtcreator即可。
工具—>选项—>Kits
本文章参考了非常多的链接,就不一一列举了,在这里表示十分的感谢,若有问题希望指正,若有侵权请提示,立马会改正。
编译过程出现了很多的错误,也不一一列举了,有问题可以评论区发一下,我能解决的会帮助各位尽量解决。
感谢