交叉編譯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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章