搭建通用Arm平台的QT交叉编译环境
- [前言](https://editor.csdn.net/md/?articleId=126960630#_1)
- [准备](https://editor.csdn.net/md/?articleId=126960630#_3)
- [一、下载arm平台交叉编译工具链](https://editor.csdn.net/md/?articleId=126960630#arm_7)
* [1.下载工具链](https://editor.csdn.net/md/?articleId=126960630#1_8)
* [2.解压到交叉编译平台(Ubuntu)](https://editor.csdn.net/md/?articleId=126960630#2Ubuntu_11)
* [3.配置环境变量](https://editor.csdn.net/md/?articleId=126960630#3_13)
- [二、下载QT源码(版本与交叉编译工具链版本保持一致)](https://editor.csdn.net/md/?articleId=126960630#QT_20)
- [三、下载并编译tslib库](https://editor.csdn.net/md/?articleId=126960630#tslib_24)
* [1. 获取 tslib](https://editor.csdn.net/md/?articleId=126960630#1__tslib_26)
* [2. 编译 tslib](https://editor.csdn.net/md/?articleId=126960630#2__tslib_30)
* [3. 生成 Makefile](https://editor.csdn.net/md/?articleId=126960630#3__Makefile_38)
- [四、配置QT源码编译工具链与编译QT源码](https://editor.csdn.net/md/?articleId=126960630#QTQT_45)
* [1. 修改qmak.conf](https://editor.csdn.net/md/?articleId=126960630#1_qmakconf_46)
* [2.生成qmake编译文件](https://editor.csdn.net/md/?articleId=126960630#2qmake_52)
- [五、编译QT源码](https://editor.csdn.net/md/?articleId=126960630#QT_140)
前言
为实现目标嵌入式平台能够正常运行Qt程序,则需要在目标平台上部署QT运行环境。本文参考08【正点原子】I.MX6U移植Qt5.12.9_V1.1.pdf ## 准备 1. Ubuntu系统,本文使用的是20.04版本 2. arm平台通用交叉编译工具链 3. QT源码一、下载arm平台交叉编译工具链
1.下载工具链
点击链接https://releases.linaro.org/components/toolchain/binaries/latest-7/arm-linux-gnueabi/,选择下图中标识的文件进行下载。
3.配置环境变量
(1)编辑.bashrc文件sudo vi ~/.bashrc
(2)添加路径
export PATH=/home/anmo/QtPorting/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin:$PATH

点击下载图中红色框框标识的压缩文件(注意可能由于平台差异,zip类型不适用于Ubuntu系统,所以请勿下载zip类型)。下载完毕之后可通过共享文件夹,或者FileZila将压缩包传输到Ubuntu。

1. 获取 tslib
获取tslib 的源码, git 地址为 https://github.com/kergoth/tslib 。 tslib 源码已经放到开发板光盘中 路径为: 开发板光盘 A 基础资料 1 、例程源码 7 、第三方库源码 tslib 1.21.tar.bz2 。将压缩包发送到 Ubuntu 中并解压至Ubuntu 虚拟机目录下,将其解压。
2. 编译 tslib
编译 tslib生成Makefile ,还需要安装以下软件 。执行autogen.sh 生成 Makefile ,以编译源码。
sudo apt get update
sudo apt get install autoconf automake libtool
3. 生成 Makefile
执行下面的指令,指令会检查编译器等是否会工作。 ,如下图。ps:
-**-host ** 指定交叉编译器,32位为arm-linux-gnueabihf,64位为aarch64-linux-gnu
-prefix **指定tslib编译输出路径,路径修改为自己的实际路径即可,**arm-tslib无需手动创建
./configure --host=arm-linux-gnueabihf ac_cv_func_malloc_0_nonnull=yes --cache-file=arm-linux.cache -prefix=/home/用户名/tslib-master/arm-tslib
执行
make
make install
四、配置QT源码编译工具链与编译QT源码
1. 修改qmak.conf
在Ubuntu解压之后,进入qtbase/mkspecd/linux-arm-gnueabi-g++路径,并编辑qmake.conf
更改编译工具链名称 32位**为arm-linux-gnueabihf,64位为aarch64-linux-gnu**

-prefix /home/用户名/qt-everywhere-src-5.12.9/arm-qt \
(2)目标平台
-xplatform linux-arm-gnueabi-g++ \ (目标机32位为linux-arm-gnueabi-g++,目标机64位为linux-arrch64-gnu-g++)
(3)之前所编译好的QT触摸库路径
-I/home/用户名/tslib-1.21/arm-tslib/include \
-L/home/用户名/tslib-1.21/arm-tslib/lib \
(2)添加权限
./configure -prefix /home/用户名/qt-everywhere-src-5.12.9/arm-qt \
-opensource \
-confirm-license \
-release \
-strip \
-shared \
-xplatform linux-arm-gnueabi-g++ \
-optimized-qmake \
-c++std c++11 \
--rpath=no \
-pch \
-skip qt3d \
-skip qtactiveqt \
-skip qtandroidextras \
-skip qtcanvas3d \
-skip qtconnectivity \
-skip qtdatavis3d \
-skip qtdoc \
-skip qtgamepad \
-skip qtlocation \
-skip qtmacextras \
-skip qtnetworkauth \
-skip qtpurchasing \
-skip qtremoteobjects \
-skip qtscript \
-skip qtscxml \
-skip qtsensors \
-skip qtspeech \
-skip qtsvg \
-skip qttools \
-skip qttranslations \
-skip qtwayland \
-skip qtwebengine \
-skip qtwebview \
-skip qtwinextras \
-skip qtx11extras \
-skip qtxmlpatterns \
-make libs \
-make examples \
-nomake tools -nomake tests \
-gui \
-widgets \
-dbus-runtime \
--glib=no \
--iconv=no \
--pcre=qt \
--zlib=qt \
-no-openssl \
--freetype=qt \
--harfbuzz=qt \
-no-opengl \
-linuxfb \
--xcb=no \
-tslib \
--libpng=qt \
--libjpeg=qt \
--sqlite=qt \
-plugin-sql-sqlite \
-I/home/用户名/tslib-1.21/arm-tslib/include \
-L/home/用户名/tslib-1.21/arm-tslib/lib \
-recheck-all
(3)执行./autoconfigure.sh 等待创建qmake
sudo chmod 755 ./autoconfigure.sh




注意请关闭当前终端窗口,重新打开一个终端窗口,为了避免在当前使用了sudo或者root用户,而在编译时出现权限访问的问题,导致编译错误 2. 最后执行make install,会在qt源码主目录下生成编译后的arm-qt文件夹,该文件夹名称为autoconfigure.sh指定的文件夹名称一致
六、配置QT Creator
- 手动添加arm交叉编译工具链
- 指定交叉编译工具链的路径
- 配置Qt Versions
- 配置kits