交叉编译Qt和tslib

作者

QQ群:852283276
微信:arm80x86
微信公众号:青儿创客基地
B站:主页 https://space.bilibili.com/208826118

参考

Qt移植到ARM64-v8平台(NXP i.MX8M)笔记
超详细Qt5.9.5移植攻略,拿走不谢
全志a64平台 arm 64位 tslib 和 qt库的小白移植
Qt移植:Ubuntu16.04 交叉编译qt5.9.6详细教程
Linux编译移植Qt5的环境_Xillinx的ZYNQ平台
Qt5.8与触摸Tslib-1.4库ARM-ZYNQ平台的移植(一)
Qt5.9+tslib1.4移植
tslib-1.4的安装与移植
解决TSLIB无法识别触摸屏的问题
Qt下载(多种下载通道+所有版本)
【转】基于Qt, TUIO和TSLIB的嵌入式Linux下的多点触摸设计
交叉编译Qt5.2.1让其支持触摸屏多点触摸
Qt5.2.1交叉编译,带tslib插件
Qt5.3.0的移植安装与测试(交叉编译,用于arm,支持tslib触摸屏)
QT5移植嵌入式触摸屏,点击位置和显示位置不对解决方法
qt多点触控
[转]ARM QT实现多点触摸
Qt源码编译configure配置参数
Enable QT developement for i.MX6UL
zcu102_A_PetaLinux运行Qt程序
IMX6Q-Yocto手工交叉编译QT5
i.MX6 Yocto QT5环境搭建流程
iMX6 yocto平台QT交叉编译环境搭建
iMX6 QT5交叉编译环境搭建for Yocto
QT支持多点触控的办法 [问题点数:50分]
Qt QWidget实现手势缩放和平移(二)
xilinx ug1209
QT5.5移植到ARM全攻略
Qt for Embedded Linux
i.mx6q 移植Qt5.6.1(含opengl)
在Hi3531上运行QT, 并对 mpp/sample/hifb/sample_hifb.c 修改
海思Hi3536移植QT5.9.8教程
海思3536:交叉编译Qt4.8.4
海思3519A 移植 Qt 5.5.1

下载

tslib Github
Qt5.9.8源码下载
libiconv

Qt国内镜像网站,Qt官网登不上的时候选择镜像,清华大学的比较好,Linux不要下载*.zip格式的源码包,文本格式和unix不兼容。

tslib

编译,以zynqmp为例,tslib-1.20,

make clean
./configure --host=aarch64-linux-gnu --prefix=$cur_path/zynqmp-$PETALINUX_VER
make 
make install

tslib只支持单点触摸,多点触摸屏需要修改数据上报部分,所以建议电容屏就不使用tslib,免得麻烦,Qt5不在一定需要tslib。

Qt5

因为Qt5.9.8支持C++11,所以编译器版本需要高于4.8以上,Xilinx Petalinux2015.2.1的GCC版本为4.9,支持,这里可以看到Qt对arm和arm64的支持,但是已经不支持powpc平台,所以T2080需要自己写mkspecs了,QorIQ-SDK-V2.0-20160527-yocto工具链的gcc版本4.9,理论上支持Qt5.9.8,arm的qmake.conf针对工具链修改,aarch64的默认的就是对的,

zc@ubuntu:~/fdk_develop/package/qt-everywhere-opensource-src-5.9.8$ ls -l qtbase/mkspecs/
total 252
...
drwxrwxr-x  2 zc zc 4096 Apr  9 04:52 linux-aarch64-gnu-g++
drwxrwxr-x  2 zc zc 4096 Apr  9 04:52 linux-arm-gnueabi-g++
...
zc@ubuntu:~/fdk_develop/package/qt-everywhere-opensource-src-5.9.8$ ls -l qtbase/mkspecs/linux-arm-gnueabi-g++/
total 8
-rw-rw-r-- 1 zc zc  766 Apr  9 04:52 qmake.conf
-rw-rw-r-- 1 zc zc 1998 Apr  9 04:52 qplatformdefs.h
zc@ubuntu:~/fdk_develop/package/qt-everywhere-opensource-src-5.9.8$ ls -l qtbase/mkspecs/linux-aarch64-gnu-g++/
total 8
-rw-rw-r-- 1 zc zc  766 Apr  9 04:52 qmake.conf
-rw-rw-r-- 1 zc zc 1998 Apr  9 04:52 qplatformdefs.h

编译,关于rpath,参考-L、-rpath和-rpath-link的区别-mtdev-xinput2选项,在help中可以找到这两个选项。mtdev包含了应用程序对多点触摸协议的支持,xinput2实现了Linux的输入子系统对多点触摸的支持。

make clean
./configure -prefix $cur_path/zynq-$PETALINUX_VER -opensource -release -pch -confirm-license -xplatform linux-arm-gnueabi-g++ -shared -iconv -qt-libpng -qt-libjpeg -no-opengl -no-cups -no-glib -no-dbus -no-rpath -no-sse2 -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 -no-avx -no-openssl
make -j4
make install

若要添加对tslib的支持?

-tslib \
-I tslib_install/include \
-L tslib_install/lib

可能会出现安装失败的情况,这不是错误,直接再编译目录下重新执行命令,可能是编译arm平台的qt有残留,所以编译失败,

$ cd qtmultimedia/
$ make clean && make -j8 && make install
$ cd qtlocation/
$ make clean && make -j8 && make install
$ make install

petalinux2018.2的gcc版本7.2.1,这个版本编译不过,大家还是不要挣扎了,用petalinux2018.3的gcc版本7.3.1

In file included from items/qquickitem_p.h:64:0,
                 from items/qquickwindow.cpp:45:
items/qquickclipnode_p.h:57:30: error: comdat-local function called by void QQuickWindowIncubationController::incubate() outside its comdat
 class Q_QUICK_PRIVATE_EXPORT QQuickDefaultClipNode : public QSGClipNode
                              ^~~~~~~~~~~~~~~~~~~~~
_ZN32QQuickWindowIncubationController28incubatingObjectCountChangedEi.part.85/24483 (virtual void QQuickWindowIncubationController::incubatingObjectCountChanged(int)) @0x1007aba7b0
  Type: function definition analyzed
  Visibility: comdat_group:_ZN32QQuickWindowIncubationController28incubatingObjectCountChangedEi artificial
  Same comdat group as: _ZN32QQuickWindowIncubationController28incubatingObjectCountChangedEi/16405
  References: 
  Referring: 
  Availability: local
  First run: 1
  Function flags: body local icf_merged split_part
  Called by: _ZN32QQuickWindowIncubationController8incubateEv.part.86/24484 (1.00 per call) _ZN32QQuickWindowIncubationController28incubatingObjectCountChangedEi/16405 (0.24 per call) 
  Calls: _ZN7QObject10startTimerEiN2Qt9TimerTypeE/23783 (0.37 per call) 
items/qquickclipnode_p.h:57:30: internal compiler error: verify_cgraph_node failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.linaro.org> for instructions.
Makefile:67514: recipe for target '.obj/qquickwindow.o' failed
make[3]: *** [.obj/qquickwindow.o] Error 1
make[3]: Leaving directory '/home/qe/program/qt-everywhere-opensource-src-5.9.6/qtdeclarative/src/quick'
Makefile:118: recipe for target 'sub-quick-install_subtargets-ordered' failed
make[2]: *** [sub-quick-install_subtargets-ordered] Error 2
make[2]: Leaving directory '/home/qe/program/qt-everywhere-opensource-src-5.9.6/qtdeclarative/src'
Makefile:59: recipe for target 'sub-src-install_subtargets' failed
make[1]: *** [sub-src-install_subtargets] Error 2
make[1]: Leaving directory '/home/qe/program/qt-everywhere-opensource-src-5.9.6/qtdeclarative'
Makefile:346: recipe for target 'module-qtdeclarative-install_subtargets' failed
make: *** [module-qtdeclarative-install_subtargets] Error 2

海思平台的fb使用需要先初始化mpp框架,首先在load3531.sh中需要配置显存,

insmod hifb.ko video="hifb:vram0_size:20000,vram1_size:7200,vram2_size:3240,vram3_size:3240,\
                vram4_size:7200,vram5_size:128,vram6_size:128" softcursor="off" u32VcmpBufNum=2\
                apszLayerMmzNames="mmzname0","mmzname1",,"graphics",,"mmzname0"

参考sample_hifb.c文件,打开HDMI接口,设置屏幕分辨率、屏幕起始坐标。程序运行后会自动结束,添加如下代码使程序在后台一直运行,然后在后台运行sample_hifb程序,再运行Qt 程序。

if (pstInfo->ctrlkey == 0)
{
	while(1)
		sleep(5);
}

hifb叠加可以将qt的GUI与海思的MPI分离,在视频层上叠加上图形层,需要修改linuxfb,再设置QT界面透明显示,
(1) 修改qt-everywhere-opensource-src-5.5.1/qtbase/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp

    for (int i = 0; i < rects.size(); i++)
    {
    // -
        //mBlitter->drawImage(rects[i], *mScreenImage, rects[i]);
    // +
    mBlitter->setCompositionMode(QPainter::CompositionMode_Source);
    mBlitter->drawImage(rects[i], *mScreenImage, rects[i]);
    mBlitter->setCompositionMode(QPainter::CompositionMode_SourceOver);
    }

(2) 修改qtbase\src\platformsupport\fbconvenience\qfbscreen.cpp

// -
//mCompositePainter->fillRect(rect, Qt::black);
//+
mCompositePainter->setCompositionMode(QPainter::CompositionMode_Source);
mCompositePainter->fillRect(rect, Qt::transparent);
mCompositePainter->setCompositionMode(QPainter::CompositionMode_SourceOver);                        

(3) 修改qt程序

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setWindowFlags(Qt::CustomizeWindowHint);
}

海思平台可能会出现安装失败的情况,可能是编译其他平台有残留,

$ cd qtimageformats/src/plugins/imageformats/tiff/
$ make clean && make -j8 && make install
$ cd qtimageformats/src/plugins/imageformats/webp/
$ make clean && make -j8 && make install
$ cd qtmultimedia/
$ make clean && make -j8 && make install
$ cd qtlocation/
$ make clean && make -j8 && make install
$ make install

编译自己的Qt应用

添加qmake到环境变量,

export QTDIR=$cur_path/zynq-$PETALINUX_VER:$QTEDIR
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
qmake
make

配置板卡环境

Qt使用电容屏
Inputs on an Embedded Linux Device
How to Build, Install and Setting Qt Application/zh

tslib配置,

export TSLIB_ROOT=/home/root/ui/tslib                                          
export TSLIB_TSDEVICE=/dev/input/event0 
export TSLIB_CALIBFILE=/etc/pointercal   
export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf    
export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts  
export TSLIB_FBDEVICE=/dev/fb0   
export TSLIB_CONSOLEDEVICE=none  
export LD_LIBRARY_PATH=$TSLIB_ROOT/lib:$LD_LIBRARY_PATH

qt配置,

export QTDIR=/home/root/ui/qt
export QT_QPA_FONTDIR=$QTDIR/lib/fonts 
export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins/ 
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH 
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0
# qt5 without tslib
export QWS_MOUSE_PROTO=/dev/input/event0
# qt with tslib
export QWS_MOUSE_PROTO=tslib:/dev/input/event0 
# or (qt with tslib)
export QT_QPA_GENERIC_PLUGINS=tslib

使用电容屏的 Qt 程序,不用移植 tslib 库,就可以直接读取输入设备文件(/etc/input/eventx),除非需要 tslib 校准,设置环境变量QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS,Qt5 自身的 libinput 就去/dev/input/eventX读取触摸屏数据,从而使触摸正常工作。将触摸屏的点击事件配置成 Qt 的鼠标点击事件后,会产生有一个鼠标光标。

export QT_LOGGING_RULES=qt.qpa.input=true # 打印触屏信息
export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event0 # 指定输入设备的名称
export QT_QPA_EVDEV_MOUSE_PARAMETERS=/dev/input/event0 # 将触摸屏的点击事件配置成Qt的鼠标点击事件
export QT_QPA_FB_HIDECURSOR=1 # 为1则隐藏鼠标光标,为0则显示鼠标光标
  • 2
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
交叉编译 Qt 5.14.2 源码,需要先安装交叉编译工具链和对应的库文件,然后使用 Qt 的 configure 工具进行配置,最后进行编译。 以下是一个简单的步骤: 1. 安装交叉编译工具链和库文件,例如 arm-linux-gnueabihf-gcc 和 libssl-dev。可以参考交叉编译工具链的文档或者咨询厂商的技术支持。 2. 下载 Qt 5.14.2 源码包,解压后进入源码目录。 3. 配置 Qt 的编译选项,使用 configure 工具。可以使用以下命令: ``` ./configure -prefix /opt/qt5 \ -release -opensource -confirm-license \ -no-icu -no-opengl -no-xcb -no-glib -no-pulseaudio \ -no-feature-bearermanagement -no-feature-ftp \ -no-feature-socks5 -no-feature-xmlstream -no-feature-xml \ -no-feature-qml-debug -no-feature-process -no-feature-sharedmemory \ -no-feature-animation -no-feature-printer -no-feature-qml-network \ -no-feature-qml -no-feature-qml-debug -no-feature-qml-designer \ -no-feature-qml-filesystem -no-feature-qml-debugger -no-feature-qml-workerscript \ -no-feature-qml-xmlhttprequest -no-feature-qml-workercontext \ -no-feature-qml-websockets -no-feature-qml-webchannel \ -no-feature-qml-mirroring -no-feature-qml-live-reload \ -no-feature-qml-context2d \ -opensource -confirm-license \ -no-sql-sqlite -no-sql-sqlite2 -no-sql-odbc -no-sql-psql \ -no-sql-mysql -no-sql-ibase -no-sql-tds -no-sql-tds \ -no-ssl -no-openssl \ -no-feature-geoservices -no-feature-geoservices-mapboxgl \ -no-feature-geoservices-nokia -no-feature-geoservices-google \ -no-feature-geoservices-here -no-feature-geoservices-mapbox \ -no-feature-geoservices-osm \ -no-feature-testlib \ -no-qml-debug \ -no-widgets \ -no-gui \ -no-iconv \ -no-compile-examples \ -no-cups \ -no-dbus \ -no-fontconfig \ -no-freetype \ -no-harfbuzz \ -no-journald \ -no-kms \ -no-linuxfb \ -no-mirclient \ -no-mtdev \ -no-pcre \ -no-pulseaudio \ -no-rpath \ -no-sm \ -no-syslog \ -no-tslib \ -no-xcb-xinput \ -no-xkbcommon \ -no-xinerama \ -no-xinput \ -no-xkb \ -no-xcursor \ -no-xfixes \ -no-xrandr \ -no-xrender \ -no-xshape \ -no-xsync \ -no-xvideo \ -no-zlib \ -no-eglfs \ -no-gbm \ -no-directfb \ -no-linuxfb \ -no-mirclient \ -no-wayland \ -no-icu \ -no-opengl \ -no-glib \ -platform linux-g++-32 \ -xplatform linux-arm-gnueabi-g++ \ -device-option CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- \ -device-option SYSROOT=/path/to/sysroot ``` 其中,-prefix 指定 Qt 的安装路径,-xplatform 指定交叉编译的平台,-device-option 指定交叉编译工具链的前缀和 sysroot 路径。 4. 执行 make 命令进行编译。 5. 执行 make install 命令进行安装。 完成以上步骤后,就能在指定的安装路径下找到交叉编译后的 Qt 库和工具了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值