1、下载编译器Linaro Releases
Linaro Releases
这里面的版本特别多,对应的版本都会不一样,如下图
需要看arm开发板是32位的还是64位的,我用的开发板是32位的,所以我下载的是gcc-linaro-7.5.0-2019.12-x86_64-arm-linux-gnueabihf.tar.xz
下载完成后,将其解压:
tar -xvf gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz
重命名:
mv gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf arm-linux-gnueabihf
将目标复制到/opt目录下:
sudo cp -rf arm-linux-gnueabihf/ /opt
安装完成后,还需要手动添加环境变量:
sudo gedit /etc/profile
将下面一行代码加入到/etc/profile的最下面:
export PATH="/opt/arm-linux-gnueabihf/bin:$PATH"
保存退出后执行下面命令,使环境变量生效:
source /etc/profile
可以检查一下有没有安装成功:
arm-linux-gnueabihf-g++ -v
显示如下,即证明安装成功:
2、下载qt-everywhere-src-5.14.2.tar.xz
注意:必须下载与自己qt版本对于的qt-everywhere,这里我下载的是:
qt-everywhere-src-5.14.2.tar.xz
下载完成后,解压:
tar xvf qt-everywhere-src-5.14.2.tar.xz
修改/qt-everywhere-src-5.14.2/qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf文件,需要将编译器的具体路径加上去,具体修改如下:
执行configure,进入路径qt-everywhere-src-5.14.2中,执行configure命令,具体参数如下:
./configure -release -nomake examples -no-iconv -no-opengl -no-assimp -no-qt3d-profile-jobs -no-qt3d-profile-gl -xplatform linux-arm-gnueabi-g++ -prefix /home/wh/qt5.14.2/qt5.14.2-arm32 -opensource -confirm-license
这里,有很多配置项,简单说明下:
-prefix选项后面的路径就是自己建的一个文件夹,用来存放编译后的qmake和其他一些配置文件
-xplatform linux-arm-gnueabi-g++ \ 就是指定编译的为ARM版本 还有一些参数,可以参考其它文章
生成命令:
sudo make -j4
安装命令:
sudo make install
以上是32位的,64位的过程是类似的
3、配置32位ARM交叉编译器
打开qt->项目->manage kits中的kits
c++
g++
qmake
kits