需要準(zhǔn)備的材料
ubuntu16.4版本虛擬機
qt5.12.9版本 ,qt-everywhere-src-5.12.9(版本要一致,沒試過版本不同是否可行)
(qt5.15.2 qt5.14.2都裝了下,按照以下流程都是完全沒錯誤)
arm-linux-g++4.8.3版本
由于最近接手公司離職員工的代碼,通常我個人都是直接寫Makefile來完成,對方用的Qt配合交叉編譯器使用的,由于代碼太亂,還有一堆沒用的源碼,目錄層次也太亂了,索性就按照人家的玩吧,頭次琢磨這個,從網(wǎng)上搜的感覺像是一些培訓(xùn)機構(gòu)里的學(xué)生把培訓(xùn)機構(gòu)教的很固有的東西直接搬上來當(dāng)教材,遇到各種問題找不到解決辦法,到處翻文檔總結(jié)了下。
在qt-everywhere-src-5.12.9目錄下創(chuàng)建了個build(看個人習(xí)慣吧,也可以直接把腳本寫在當(dāng)前的目錄),在這個目錄下寫了個腳本,configure.sh ,用來執(zhí)行configure配置信息的。
這個配置相當(dāng)關(guān)鍵了,之前弄了好幾天,懷疑主要錯誤就是在這個配置不當(dāng)上了
#! /bin/sh
../configure \
-prefix /home/wht/qt5.15.2-arm \
-opensource \
-confirm-license \
-release \
-xplatform linux-arm-guneabi-g++ \
-make libs \
-nomake examples \
-nomake tools \
-nomake tests \
-no-openssl \
-no-opengl \
-skip qt3d \
-skip qtactiveqt \
-skip qtandroidextras \
-skip qtcharts \
-skip qtconnectivity \
-skip qtdatavis3d \
-skip qtdeclarative \
-skip qtdoc \
-skip qtgamepad \
-skip qtimageformats \
-skip qtlocation \
-skip qtmacextras \
-skip qtmultimedia \
-skip qtnetworkauth \
-skip qtpurchasing \
-skip qtquickcontrols \
-skip qtquickcontrols2 \
-skip qtremoteobjects \
-skip qtscript \
-skip qtscxml \
-skip qtsensors \
-skip qtserialbus \
-skip qtserialport \
-skip qtspeech \
-skip qtsvg \
-skip qttools \
-skip qttranslations \
-skip qtvirtualkeyboard \
-skip qtwayland \
-skip qtwebchannel \
-skip qtwebglplugin \
-skip qtwebsockets \
-skip qtwebview \
-skip qtwinextras \
-skip qtx11extras \
-skip qtxmlpatterns
-prefix 這個配置用來生成的文件保存的目錄
-xplatform 配置交叉編譯器的腳本(這里要配置一個文件)
-skip 都是跳過的信息 ,如果有哪些模塊是自己使用的,可以刪掉
要注意了 \ 換行后面不要有空格,有些人會用windows寫腳本,容易發(fā)生/bin/sh^M:這個解釋器的錯誤,如果遇到了搜搜 sed命令來解決 換行問題。
qt-everywhere-src-5.12.9/qtbase/mkspecs/ 這個路徑下配置使用的交叉編譯器(關(guān)于交叉編譯器配置,滿網(wǎng)站都是,隨處可以搜的到)
可以創(chuàng)建一個新的目錄用來配置,也可以直接選個覺得自己有用的就可以了,我個人是在本來就有的一個路徑linux-arm-gnueabi-g++目錄下 qmake.conf 以下為內(nèi)容
#
# qmake configuration for building with arm-linux-gnueabi-g++
#
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
# modifications to g++.conf
QMAKE_CC = arm-linux-gcc
QMAKE_CXX = arm-linux-g++
QMAKE_LINK = arm-linux-g++
QMAKE_LINK_SHLIB = arm-linux-g++
# modifications to linux.conf
QMAKE_AR = arm-linux-ar cqs
QMAKE_OBJCOPY = arm-linux-objcopy
QMAKE_NM = arm-linux-nm -P
QMAKE_STRIP = arm-linux-strip
load(qt_config)
回到build目錄下執(zhí)行configure.sh腳本,成功后顯示 'run make’的字樣,無ERROR,執(zhí)行make(好多帖子使用多線程make,各種問題,就直接make吧,多線程也沒節(jié)省多少時間)
如果使用其他的qt版本,遇到以下問題,直接刪除這行,我這個是按照qt5.12.9版本的模塊,有些版本可能模塊不同,以下這個錯誤是當(dāng)時用5.15.2版本后,直接把腳本放到5.12.9上使用,突然發(fā)現(xiàn)有些模塊是沒有的。
Project ERROR: -skip command line argument used with non-existent module ‘qtlottie’.
執(zhí)行完畢沒有錯誤,就是下面這提示,運行 make指令了,這個過程相當(dāng)長了,我這公司的電腦運行了2-3小時才結(jié)束,結(jié)束沒錯誤后,make install
由于我在執(zhí)行過程中完全沒遇到錯誤,如果看到帖子的有遇到問題的,歡迎留言。
最后一步配置QtCreator使用交叉編譯器 (由于我這個當(dāng)前的還沒make完,所以用了之前做好了的5.15.2的做演示,添加配置都一樣的)
瀏覽的是自己存放交叉編譯器的地方,我這里是使用了arm-linux-g++的,兩個都添加下。
看到藍色的地方,就是之前-prefix 配置的目錄,找到bin目錄,里面有個qmake。
這里出現(xiàn)了個黃嘆號 NO QML utility installed ,我也沒整明白啥錯誤,也沒解決,但是我試了下,可以正常編譯,所以就沒理這個錯誤。
把前面添加的qmake 和 交叉編譯器路徑信息添加后 OK
文章來源:http://www.zghlxwxcb.cn/news/detail-806351.html
編譯成功文章來源地址http://www.zghlxwxcb.cn/news/detail-806351.html
到了這里,關(guān)于QT配置arm-linux-g++交叉編譯器的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!