交叉编译qt5

qt5.9.9源码下载地址:http://download.qt.io/archive/qt/5.9/5.9.9/single/qt-everywhere-opensource-src-5.9.9.tar.xz

gcc编译器下载地址:http://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/arm-linux-gnueabihf/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz

在Linux环境下用wget就可以下载源码和编译器。

一、编译工具链配置:

1、编译器下载下来后解压到一个目录,比如我这里是:/home/dave/toolchain/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf

2、环境变量配置,在用户目录下打开文件:.profile这个文件,在最后加上:

export PATH=$PATH:/home/dave/toolchain/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin

保存后执行source .profile 使环境变量生效

二、编译qt5:

1、解压源码后进入源码目录:tar -xvf qt-everywhere-opensource-src-5.9.9.tar.xz

2、修改源码目录下的文件qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf,替换里面所有的arm-linux-gnueabiarm-linux-gnueabihf

3、编写一个shell脚本build.sh来执行编译,脚本内容为:

#!/bin/sh

#export PATH=$PATH:/home/dave/toolchain/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin

./configure -prefix $PWD/qt5.9-arm \
-opensource \
-release \
-confirm-license \
-xplatform linux-arm-gnueabi-g++ \
-no-opengl \
-no-pch \
-shared \
-no-iconv \
-no-xcb \
-nomake examples \
-nomake tests \


make -j 4

make install
 

其中,qt5.9-arm是编译后生成文件的目录,-nomake examples指明不编译example,-nomake tests指明不编译test

4、写好脚本那就执行脚本编译吧:

chmod a+x build.sh

./build.sh

猜你喜欢

转载自blog.csdn.net/m0_46455711/article/details/105685463
Qt5