赞
踩
ARM开发板上运行Qt程序,并实现触摸功能
第一,需要第三方触摸库
第二,需要交叉编译Qt
第三,需要配置开发板的环境变量
总体分为几个部分:
1、触摸库tslib库或者使用qTUIO,tslib低版本只能单点触控,高版本可以实现多点触控,qUIO能实现多点触控,本教程主要使用tslib
2、编译Qt源码并移植到开发板的根文件系统下
3、设置环境变量/etc/profile文件
接下来详细说一下配置步骤
使用git获取最新源码
sudo git clone https://github.com/15903016222/tslib.git
sudo ./autogen.sh
./configure --prefix=/home/yzm/Linux/nfs/rootfs/tslib --host= arm-none-linux-gnueabihf-gcc
make clean
make
make install
运行以上代码的过程中可能会因为主机ubuntu版本不同而出现一些错误,一般就是源码缺失头文件,在出现错误的源码文件中加入缺失的头文件就可以了。make install后就会在设置的路径下生成以下文件:
tslib文件夹的内容出现这些就证明编译成功。
首先,先去官网下载Qt5.12.9的源码,链接:Qt下载地址
下载后解压,更改配置文件
vim qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf # # 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 = /usr/local/arm/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-gcc QMAKE_CXX = /usr/local/arm/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-g++ QMAKE_LINK = /usr/local/arm/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-g++ QMAKE_LINK_SHLIB = /usr/local/arm/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-g++ # modifications to linux.conf QMAKE_AR = /usr/local/arm/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-ar cqs QMAKE_OBJCOPY = /usr/local/arm/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-objcopy QMAKE_NM = /usr/local/arm/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-nm -P QMAKE_STRIP = /usr/local/arm/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-strip<font face="黑体"></font> load(qt_config)
交叉编译器根据自己的交叉编译器修改。
然后创建一个脚本
vim autoConfigure.sh
chmod 777 autoConfigure.sh
./autoConfigure
内容如下
#!/bin/bash ./configure -prefix /home/yzm/Linux/nfs/rootfs/arm_qt \ -release \ -opensource \ -no-accessibility \ -make libs \ -xplatform linux-arm-gnueabi-g++ \ -optimized-qmake \ -pch \ -qt-zlib \ -qt-freetype \ -tslib \ -skip qtlocation \ -no-iconv \ -skip qtdeclarative \ -no-opengl \ -no-sse2 \ -no-openssl \ -no-cups \ -no-glib \ -no-pkg-config \ -no-separate-debug-info \ -tslib \ -I/home/yzm/Linux/nfs/rootfs/tslib/include \ -L/home/yzm/Linux/nfs/rootfs/tslib/lib \ -recheck-all
然后编译
make
make install
cd /etc/profile export TSLIB_TSDEVICE=/dev/input/event0 export TSLIB_ROOT=/tslib/lib export TSLIB_TSDEVICE=/dev/input/event0 export TSLIB_FBDEVICE=/dev/fb0 export TSLIB_CONFFILE=/tslib/etc/ts.conf export TSLIB_PLUGINDIR=/tslib/lib/ts export TSLIB_CONSOLEDEVICE=none export TSLIB_CALIBFILE=/tslib/calibration export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tslib/lib export QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/event0 export QT_QPA_FONTDIR=/arm_qt/lib/fonts export QT_QPA_PLATFORM_PLUGIN_PATH=/arm_qt/plugins export QT_QPA_PLATFORM=linuxfb:tty=/dev/fb0 export TSLIB_CALIBFILE=/etc/pointercal export QT_PLUGIN_PATH=/arm_qt/plugins/ export LD_LIBRARY_PATH=/arm_qt/lib:$TSLIB_ROOT/lib export LD_PRELOAD=$TSLIB_ROOT/lib/libts.so source /etc/profile
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。