|
https://blog.csdn.net/christine14122/article/details/83621585
博主是嵌入式小萌新,項目需要移植qt到arm開發(fā)板上,歷經(jīng)千辛萬苦解決了各種問題,最后終于成功了,所以整理了開發(fā)筆記給更多的小伙伴參考。
1.準(zhǔn)備階段
①下載交叉編譯器aarch65-linux-gnu,下載地址為:https://releases./components/toolchain/binaries/6.2-2016.11/aarch64-linux-gnu/

②下載Qt5.9.6源碼,下載地址為:http://download./archive/qt/5.9/5.9.6/single/

③下載Qtcreator安裝包,下載地址為:http://download./archive/qt/5.9/5.9.6/

④安裝虛擬機VMware? Workstation 14 Pro和Ubuntu16.04.5 LTS,博主的虛擬機版本如下圖:

⑤將文件分別存放在相應(yīng)文件夾下并解壓:

****.tar.gz 文件的解壓命令是 :tar -zxvf ****.tar.gz
****.tar.xz 文件的解壓命令是 :tar xvJf ****.tar.xz
第一步的準(zhǔn)備工作已完成。
2. 安裝交叉編譯器:
交叉編譯器解壓之后的路徑為:/home/admin/Qt_Env/Cross-compiler/
①查看當(dāng)前環(huán)境變量命令:echo $PATH

②在/etc/profile中添加新的環(huán)境變量:
-
執(zhí)行命令:gedit /etc/profile
-
在文件末尾添加:export PATH=$PATH:/home/admin/Qt_Env/Cross-compiler/aarch64-linux-gnu/bin
-
執(zhí)行命令:source /etc/profile
③再次執(zhí)行echo $PATH

可以看到環(huán)境變量已經(jīng)添加上了。
④驗證編譯器是否安裝成功
終端顯示編譯器信息如下:

編譯器安裝成功。
注意:在/etc/profile中改變的環(huán)境變量是臨時的,重啟虛擬機或重啟終端會導(dǎo)致環(huán)境變量修改不生效,所以在編譯qt之前一定要確定交叉編譯器安裝成功,如果執(zhí)行④打印的是gcc的版本信息,那么可能是編譯器路徑不對,或者多執(zhí)行幾次source /etc/profile即可。
3.交叉編譯qt5.9.6
①配置qt的configure
在目錄/home/Qt_Env/Qt_opensource下創(chuàng)建 qt_compiler_conf.sh文件,文件是configure的配置項,關(guān)于配置項的說明資料很多,在此不在贅述。
./configure -prefix /opt/aarch64/qt596_64/qt_sdk \ -xplatform linux-arm-gnueabi-g++ \
②修改qmake文件
安裝目錄打開:/home/hytera/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtbase/mkspecs/linux-arm-gnueabi-g++,打開qmake.conf文件,修改編譯器:
# qmake configuration for building with arm-linux-gnueabi-g++ MAKEFILE_GENERATOR = UNIX QMAKE_INCREMENTAL_STYLE = sublib include(../common/linux.conf) include(../common/gcc-base-unix.conf) include(../common/g++-unix.conf) QT_QPA_DEFAULT_PLATFORM=linuxfb # modifications to g++.conf QMAKE_CC = aarch64-linux-gnu-gcc QMAKE_CXX = aarch64-linux-gnu-g++ QMAKE_LINK = aarch64-linux-gnu-g++ QMAKE_LINK_SHLIB = aarch64-linux-gnu-g++ # modifications to linux.conf QMAKE_AR = aarch64-linux-gnu-ar cqs QMAKE_OBJCOPY = aarch64-linux-gnu-objcopy QMAKE_NM = aarch64-linux-gnu-nm -P QMAKE_STRIP = aarch64-linux-gnu-strip
注意:arm開發(fā)板上顯示屏的驅(qū)動是基于fb的話,記得在文件中添加QT_QPA_DEFAULT_PLATFORM=linuxfb。
③執(zhí)行qt_compiler_conf.sh配置文件
※ 在終端執(zhí)行命令:./qt_compiler_conf.sh
※ 或者,博主將終端打印的日志重定向到了confLog.txt文件中,方便查看,故執(zhí)行的命令是:./qt_compiler_conf.sh 2>&1 | tee confLog.txt
※ 執(zhí)行結(jié)果為:
+ /home/hytera/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtbase/configure -top-level -prefix /opt/aarch64/qt596_64/qt_sdk -opensource -debug -confirm-license -xplatform linux-arm-gnueabi-g++ -no-opengl -no-pch -shared -no-iconv -xcb This is the Qt Open Source Edition. You have already accepted the terms of the Open Source license. Running configuration tests... Done running configuration tests. Building on: linux-g++ (x86_64, CPU features: mmx sse sse2) Building for: linux-arm-gnueabi-g++ (arm64, CPU features: neon) Configuration: cross_compile compile_examples enable_new_dtags largefile neon optimize_debug shared rpath debug c++11 c++14 c++1z concurrent dbus no-pkg-config reduce_exports release_tools stl Mode ................................... debug; optimized tools Optimize debug build ................... yes Building shared libraries .............. yes Using C++ standard ..................... C++1z Using ccache ........................... no Using gold linker ...................... no Using new DTAGS ........................ yes Using precompiled headers .............. no Using LTCG ............................. no Target compiler supports: NEON ................................. yes Build parts ............................ libs examples Qt Concurrent .......................... yes Qt D-Bus ............................... yes Qt D-Bus directly linked to libdbus .... no Qt Gui ................................. yes Qt Network ............................. yes Qt Sql ................................. yes Qt Testlib ............................. yes Qt Widgets ............................. yes Qt Xml ................................. yes Using pkg-config ....................... no QML debugging .......................... yes udev ................................... no Using system zlib ...................... no DoubleConversion ....................... yes Using system DoubleConversion ........ no GLib ................................... no iconv .................................. no ICU .................................... no journald ............................. no syslog ............................... no slog2 ................................ no Using system PCRE2 ..................... no getaddrinfo() .......................... yes getifaddrs() ........................... yes IPv6 ifname ............................ yes libproxy ............................... no OpenSSL ................................ no Qt directly linked to OpenSSL ........ no SCTP ................................... no Use system proxies ..................... yes Accessibility .......................... yes FreeType ............................... yes Using system FreeType ................ no HarfBuzz ............................... yes Using system HarfBuzz ................ no Fontconfig ............................. no GIF .................................. yes ICO .................................. yes JPEG ................................. yes Using system libjpeg ............... no PNG .................................. yes Using system libpng ................ no EGL .................................... no OpenVG ................................. no Desktop OpenGL ....................... no OpenGL ES 2.0 ........................ no OpenGL ES 3.0 ........................ no OpenGL ES 3.1 ........................ no Session Management ..................... yes Features used by QPA backends: evdev .................................. yes libinput ............................... no INTEGRITY HID .......................... no mtdev .................................. no tslib .................................. no xkbcommon-evdev ........................ no DirectFB ............................... no EGLFS .................................. no LinuxFB ................................ yes VNC .................................... yes Mir client ............................. no GTK+ ................................... no Styles ................................. Fusion Windows CUPS ................................... no DB2 (IBM) .............................. no InterBase .............................. no MySql .................................. no OCI (Oracle) ........................... no ODBC ................................... no PostgreSQL ............................. no SQLite2 ................................ no SQLite ................................. yes Using system provided SQLite ......... no TDS (Sybase) ........................... no Socket CAN ............................. yes Socket CAN FD .......................... yes XML schema support ..................... yes QML interpreter ........................ yes QML network support .................... yes Direct3D 12 ............................ no AnimatedImage item ..................... yes Canvas item ............................ yes Support for Qt Quick Designer .......... yes Flipable item .......................... yes GridView item .......................... yes ListView item .......................... yes Path support ........................... yes PathView item .......................... yes Positioner items ....................... yes ShaderEffect item ...................... yes Sprite item ............................ yes SDL2 ................................... no Assimp ................................. yes System Assimp .......................... no Output Qt3D Job traces ................. no Output Qt3D GL traces .................. no Autodesk FBX ........................... no Qt Wayland Client ........................ no Qt Wayland Compositor .................... no BlueZ .................................. no BlueZ Low Energy ....................... no Linux Crypto API ....................... no sensorfw ............................... no Styles ................................. Default Material Universal Hover support .......................... yes Multi-touch support .................... yes Gypsy GPS Daemon ....................... no WinRT Geolocation API .................. no OpenStreetMap ........................ yes HERE ................................. yes Esri ................................. yes Mapbox ............................... yes MapboxGL ............................. no Itemsoverlay ......................... yes ALSA ................................... no GStreamer 1.0 .......................... no GStreamer 0.10 ......................... no Video for Linux ........................ yes OpenAL ................................. no PulseAudio ............................. no Resource Policy (libresourceqt5) ....... no Windows Audio Services ................. no DirectShow ............................. no Windows Media Foundation ............... no Embedded build ......................... yes Pepper Plugins ......................... no Printing and PDF ....................... no Proprietary Codecs ..................... no Spellchecker ........................... yes WebRTC ................................. no Using system ninja ..................... no ALSA ................................... no PulseAudio ............................. no re2 .................................. no ICU .................................. no libwebp and libwebpdemux ............. no Opus ................................. no ffmpeg ............................... no Note: Also available for Linux: linux-clang linux-icc Note: No wayland-egl support detected. Cross-toolkit compatibility disabled. Qt is now configured for building. Just run 'make'. Once everything is built, you must run 'make install'. Qt will be installed into '/opt/aarch64/qt596_64/qt_sdk'. Prior to reconfiguration, make sure you remove any leftovers from
④執(zhí)行make并重定向到makeLog.txt
命令為:make -j4 2>&1 | tee makeLog.txt
這個過程時間比較久,根據(jù)電腦性能,半個小時到六個小時不等。執(zhí)行完成后的makeLog.txt如下,可以打開makeLog.txt,檢索是否有error,如果沒有,那就順利編譯通過啦?。?!
----------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------- make[4]: Leaving directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtnetworkauth/examples/oauth/twittertimeline' make[3]: Leaving directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtnetworkauth/examples/oauth' make[2]: Leaving directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtnetworkauth/examples' make[1]: Leaving directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtnetworkauth'
⑤執(zhí)行make install安裝命令,并重定向到installLog.txt
命令為:make install 2>&1 | tee installLog.txt
installLog.txt的內(nèi)容如下,打開文件檢測是否有error。
------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------- make[2]: Leaving directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qttranslations/translations' make[1]: Leaving directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qttranslations' cd qtdoc/ && ( test -e Makefile || /home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtbase/bin/qmake -o Makefile /home/hytera/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtdoc/qtdoc.pro ) && make -f Makefile install make[1]: Entering directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtdoc' cd doc/ && ( test -e Makefile || /home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtbase/bin/qmake -o Makefile /home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtdoc/doc/doc.pro ) && make -f Makefile install make[2]: Entering directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtdoc/doc' make[2]: Nothing to be done for 'install'. make[2]: Leaving directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtdoc/doc' make[1]: Leaving directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtdoc'
完成這一步,qt編譯成功。
4. 將qt移植到arm開發(fā)板并運行example程序
這一部分內(nèi)容較多,將在博主的另一篇博文中介紹。
|