Linux4.9.7 + aarch64-linux-gun 4.7 交叉编译QT5.12.9

1.下载安装交叉编译器

2、设置交叉编译器环境变量

使用 vi 指令编辑/etc/profile 这个文件。
sudo vi /etc/profile
打开/etc/profile 以后,在末尾添加如下所示内容。

如:   export PATH=$PATH:/usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin

添加完成如下图,保存退出,重启系统。

aarch64-linux-gun-gcc -v  查看gcc版本信息

aarch64-linux-gun-g++ -v 查看g++版本信息

3、添加 Qt 支持触摸库 tslib

下载地址:https://github.com/kergoth/tslib

编译方式 :

编译 tslib
生成 Makefile,还需要安装以下软件。
sudo apt-get update
sudo apt-get install autoconf automake libtool
执行 autogen.sh 生成 Makefile,以编译源码。

 

执行预编译:

./configure –host=arm-linux-gnueabihf ac_cv_func_malloc_0_nonnull=yes –cache-file=arm-linux.
cache -prefix=/home/alientek/tslib-1.21/arm-tslib

直接执行 make 编译及 make install 安装。
make
make install

4、编译QT源码

创建预编译脚本:autoconfigure.sh

./configure -prefix /home/forlinx/work/qt-everywhere-src-5.12.9/arm-qt \
-opensource \
-confirm-license \
-release \
-strip \
-shared \
-xplatform linux-aarch64-gnu-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/forlinx/work/tslib/arm-tslib/include \
-L/home/forlinx/work/tslib/arm-tslib/lib \
-recheck-all

说明:

(1) /home/forlinx/work/qt-everywhere-src-5.12.9/arm-qt 为编译输出路径。
(2) /home/forlinx/work/tslib/arm-tslib/include 为第二章 tslib 头文件路径。
(3) /home/forlinx/work/tslib/arm-tslib/lib 为第二章 tslib 相关库文件路径。

 

直接执行 make 开始编译。
time (make -j 16) // -j 16 代表最多允许 16 条编译指令同时运行,参数 16,一般为
个人分配给虚拟机的核心数的 2 倍,前面加个 time 是测试编译时间。

make intsall 安装