前言
為實(shí)現(xiàn)目標(biāo)嵌入式平臺能夠正常運(yùn)行Qt程序,則需要在目標(biāo)平臺上部署QT運(yùn)行環(huán)境。
準(zhǔn)備
- Ubuntu系統(tǒng),本文使用的是20.04版本
- arm平臺通用交叉編譯工具鏈
- QT源碼
一、下載arm平臺交叉編譯工具鏈
1.下載工具鏈
點(diǎn)擊鏈接https://releases.linaro.org/components/toolchain/binaries/latest-7/arm-linux-gnueabi/,選擇下圖中標(biāo)識的文件進(jìn)行下載。
2.解壓到交叉編譯平臺(Ubuntu)
通過共享文件夾或者FileZila將該壓縮文件傳輸?shù)経buntu,并解壓。
3.配置環(huán)境變量
(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
二、下載QT源碼(版本與交叉編譯工具鏈版本保持一致)
點(diǎn)擊鏈接https://download.qt.io/archive/qt/5.12/5.12.9/single/,跳轉(zhuǎn)到QT官網(wǎng)下載中心進(jìn)行下載,本文以5.12.9版本的QT源碼為例(如需要其他版本,點(diǎn)擊”Parent Directory“返回上級目錄自行選擇)。
點(diǎn)擊下載圖中紅色框框標(biāo)識的壓縮文件(注意可能由于平臺差異,zip類型不適用于Ubuntu系統(tǒng),所以請勿下載zip類型)。下載完畢之后可通過共享文件夾,或者FileZila將壓縮包傳輸?shù)経buntu。
三、下載并編譯tslib庫
該庫為ArmQt的屏幕觸摸庫
1. 獲取 tslib
獲取tslib 的源碼, git 地址為 https://github.com/kergoth/tslib 。 tslib 源碼已經(jīng)放到開發(fā)板光
盤中 路徑為: 開發(fā)板光盤 A 基礎(chǔ)資料 1 、例程源碼 7 、第三方庫源碼 tslib 1.21.tar.bz2 。將壓縮包發(fā)送到 Ubuntu 中并解壓至Ubuntu 虛擬機(jī)目錄下,將其解壓。
2. 編譯 tslib
編譯 tslib生成Makefile ,還需要安裝以下軟件 。
sudo apt get update
sudo apt get install autoconf automake libtool
執(zhí)行autogen.sh 生成 Makefile ,以編譯源碼。
3. 生成 Makefile
執(zhí)行下面的指令,指令會檢查編譯器等是否會工作。 ,如下圖。
./configure --host= arm-linux-gnueabihf ac_cv_func_malloc_0_nonnull=yes --cache-file=arm -linux.cache -prefix=/home/用戶名/tslib-master/arm-tslib
ps:指定tslib編譯輸出路徑-prefix=/home/用戶名/tslib-master/arm-tslib
四、配置QT源碼編譯工具鏈與編譯QT源碼
1. 修改qmak.conf
在Ubuntu解壓之后,進(jìn)入qtbase/mkspecd/linux-arm-gnueabi-g++路徑,并編輯qmake.conf
更改編譯工具鏈名稱
2.生成qmake編譯文件
(1)在qt源碼主目錄下,新建配置腳本autoconfigure.sh,添加如下內(nèi)容。
./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
(2)添加權(quán)限
sudo chmod 755 ./autoconfigure.sh
(3)執(zhí)行./a等待創(chuàng)建qmake
(4)輸入o,表示開源版本
(5)輸入y,接受許可
(6)配置完成文章來源:http://www.zghlxwxcb.cn/news/detail-414712.html
五、編譯QT源碼
(1)執(zhí)行make -j 12,進(jìn)行編譯
注意請關(guān)閉當(dāng)前終端窗口,重新打開一個(gè)終端窗口,為了避免在當(dāng)前使用了sudo或者root用戶,而在編譯時(shí)出現(xiàn)權(quán)限訪問的問題,導(dǎo)致編譯錯(cuò)誤
(2)最后執(zhí)行make install,會在qt源碼主目錄下生成編譯后的文件夾,該文件夾名稱為autoconfigure.sh指定的文件夾名稱一致。文章來源地址http://www.zghlxwxcb.cn/news/detail-414712.html
到了這里,關(guān)于【一、搭建通用Arm平臺的QT交叉編譯環(huán)境】的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!