您好,登錄后才能下訂單哦!
本篇內容主要講解“QT5交叉編譯怎么實現”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“QT5交叉編譯怎么實現”吧!
./configure -release -opensource -prefix <path> -no-largefile -no-pkg-config -no-qml-debug -xplatform <target> -qt-libpng -qt-zlib -qt-libjpeg -qt-freetype -qt-sql-sqlite -plugin-sql-sqlite -no-harfbuzz -no-openssl -no-libproxy -make libs -nomake tests -nomake examples -gui -widgets -no-cups -no-tslib -iconv -pch -no-c++11
在qtbase/mkspecs/目錄下根據相近的平臺創建對應的目標工具編譯配置目錄,如參考目錄下的linux-arm-gnueabi-g++創建
The Qt Platform Abstraction (QPA) is the platform abstraction layer for Qt 5 and replaces Qt for Embedded Linux and the platform ports from Qt 4.
QT_QPA_DEFAULT_PLATFORM = linuxfb QMAKE_CFLAGS_RELEASE += -O2 -march=armv5te QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv5te
QT_QPA_DEFAULT_PLATFORM是必須的,通常在mac上是cocoa,在window上是windows,在linuxX11下是xcb,如果有OPENGL支持,那么選eglfs. 對于無硬件加速的設備,選擇linuxfb,minimal僅僅是讓程序跑通,不起任何作用(看不到界面).QPA是QT Platform Abstraction的縮寫.
tslib代表QT對觸摸板的支持,需要額外添加tslib庫的鏈接,-I 和L后面分別為為第一步編譯tslib的include和lib的安裝目錄。
Qt5.7的版本連編譯的時候都要gcc編譯器支持c++11才能通過configure。
-c++std <edition> .. Compile Qt with C++ standard edition (c++11, c++14, c++1z) Default: highest supported
Qt5.6.2及以前的版本通過添加-no-c++11的配置項,可以用c++98編譯,提示:
NOTICE: The -no-c++11 / --c++-level=c++98 option is deprecated. Qt 5.7 will require C++11 support. The options are in effect for this Qt 5.6 build, but you should update your build scripts to remove the option and, if necessary, upgrade your compiler.
make -j4 module-qtbase
問題一:error :expected initializer before “throw”
上面這個問題我自己解決了,在主機目錄 /usr/include/i386-linux-gnu/sys/signalfd.h 文件中 signalfd 定義如下
extern int signalfd (int __fd, const sigset_t *__mask, int __flags) __THROW __nonnull ((2));
而海思交叉編譯工具目錄下 signalfd.h 文件中 signalfd 定義如下
extern int signalfd (int __fd, const sigset_t *__mask, int __flags) __nonnull ((2)) __THROW;
把 __nonnull ((2)) 和 __THROW 前后調換一下就可以了。
QPA插件編譯
目錄:qtbase/src/plugins/platforms 庫文件:qtbase/plugins/platforms/
問題一:QT_QPA_DEFAULT_PLATFORM = linux #eglfs
# ./basiclayouts This application failed to start because it could not find or load the Qt platform plugin "linux #eglfs" in "". Reinstalling the application may fix this problem. Aborted
修改QT_QPA_DEFAULT_PLATFORM的值為linuxfb,拷貝插件libqlinuxfb.so到開發機器上。問題仍然出現,解決辦法:設置相應的環境變量。
export QT_PLUGIN_PATH=/mnt/3520d/qt5.6.2/plugins
將qtbase/src/plugins/platforms目錄內容(整個目錄)都拷貝到環境變量指定的目錄下面。
問題二:字體文件
# ./basiclayouts QFontDatabase: Cannot find font directory /home/lzh/qt/qt-everywhere-opensource-src-5.6.2/hi3520d-uclibc/lib/fonts - is Qt installed correctly? QFontDatabase: Cannot find font directory /home/lzh/qt/qt-everywhere-opensource-src-5.6.2/hi3520d-uclibc/lib/fonts - is Qt installed correctly? QFontDatabase: Cannot find font directory /home/lzh/qt/qt-everywhere-opensource-src-5.6.2/hi3520d-uclibc/lib/fonts - is Qt installed correctly? QFontDatabase: Cannot find font directory /home/lzh/qt/qt-everywhere-opensource-src-5.6.2/hi3520d-uclibc/lib/fonts - is Qt installed correctly?
解決辦法:設置字體環境變量
export QT_QPA_FONTDIR=/mnt/3520d/qt5.6.2/lib/fonts
Qt normally uses fontconfig to provide access to system fonts. If fontconfig is not available, Qt will fall back to using QBasicFontDatabase. In this case, Qt applications will look for fonts in Qt's lib/fonts directory. Qt will automatically detect pre-rendered fonts and TrueType fonts. This directory can be overridden by setting the QT_QPA_FONTDIR environment variable.
可以通過設置QT_QPA_PLATFORM環境變量或者是在命令行指定 -platform 選項來選擇響應的顯示插件(eglfs, xcb, linuxfb等).
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb1
linuxfb自帶libinput支持,只需要設置環境變量就好了。
export QT_QPA_EVDEV_MOUSE_PARAMETERS="usb:/dev/event0"
支持熱插拔需要構建的QT支持libudev:
Hot plugging is supported, but only if Qt was configured with libudev support (that is, if the libudev development headers are present in the sysroot at configure time). This allows connecting or disconnecting an input device while the application is running.
export QT_QPA_EVDEV_KEYBOARD_PARAMETERS="usb:/dev/event3"
PNG與JPEG格式圖片的支持,在構建QT時需要配置相應的選項:
PNG: -qt-libpng, QT5自帶支持 JPG:-qt-libjpeg, 需要編譯插件支持
對于JPEG的支持,除了增加構建選項外,還需要將對應的jpeg插件拷貝到設備上去,才能正確地處理圖片。
圖像插件代碼目錄在:qtbase/src/plugins/imageformats
構建成功的插件庫位置在:qtbase/plugins/imageformats
將imageformats目錄拷貝到設備上,同時設置QT的插件路徑環境變量,與前面的QPA插件一致。
export QT_PLUGIN_PATH=/mnt/3520d/qt5.6.2/plugins
此外,JPEG圖片不支持透明度功能。
到此,相信大家對“QT5交叉編譯怎么實現”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。