网站首页 > 技术文章 正文
configure 配置
./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++ 创建
QT_QPA_DEFAULT_PLATFORM 选项
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
构建指定模块
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开发教程学习资料,点击下方链接莬费领取↓↓,先码住不迷路~】
点击→领取「链接」
运行
- 问题一: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 等).
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 图片不支持透明度功能。
- 上一篇: Qt 6.x时代,哪些新功能值得期待?
- 下一篇: Qt Deployment查找Plugin过程
猜你喜欢
- 2025-01-07 推荐一款支持40+通讯协议的强大工业调试软件
- 2025-01-07 2024年windows原生应用用什么框架开发?
- 2025-01-07 基于跨平台的实时数据处理系统的设计
- 2025-01-07 一文分析QtCreator中MSVC编译套件
- 2025-01-07 C++Qt开发——事件处理函数
- 2025-01-07 Qt开发——NotePad实例开发
- 2025-01-07 解决Linux 下QT Creator 无法输入中文
- 2025-01-07 (1) 安装配置 pyqt5(windows),使用designer设计工具
- 2025-01-07 Linux平台上的PHP IDE盘点
- 2025-01-07 Ubuntu 24.04 解决运行 Flameshot 报错:Unable to capture screen
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- oraclesql优化 (66)
- 类的加载机制 (75)
- feignclient (62)
- 一致性hash算法 (71)
- dockfile (66)
- 锁机制 (57)
- javaresponse (60)
- 查看hive版本 (59)
- phpworkerman (57)
- spark算子 (58)
- vue双向绑定的原理 (68)
- springbootget请求 (58)
- docker网络三种模式 (67)
- spring控制反转 (71)
- data:image/jpeg (69)
- base64 (69)
- java分页 (64)
- kibanadocker (60)
- qabstracttablemodel (62)
- java生成pdf文件 (69)
- deletelater (62)
- com.aspose.words (58)
- android.mk (62)
- qopengl (73)
- epoch_millis (61)
本文暂时没有评论,来添加一个吧(●'◡'●)