在交叉编译QT前,需要先交叉编译触摸屏校准
触摸校准源码github地址
https://github.com/libts/tslib.git
下载源码-v1.12版本
wget https://github.com/libts/tslib/releases/download/1.12/tslib-1.12.tar.xz
配置源码,生成Makefile文件
./configure –host=arm-linux ac_cv_func_malloc_0_nonnull=yes CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++ -prefix=/usr/local/tslib |
说明:
–prefix 安装路径
–host 平台
–target-os 系统
CC 交叉编译器gcc名称
CXX 交叉编译器g++名称
编译
make -j4
安装到指定目录
make install
将tslib安装路径下的所有文件,拷贝至arm linux最小根文件系统的/usr/local/目录
下载QT5.7.0源码,源码的版本尽量与开发环境版本一致,QT开发环境安装见上一篇博客
https://download.qt.io/archive/qt/5.7/5.7.0/single/qt-everywhere-opensource-src-5.7.0.tar.xz
解压
tar -vxf qt-everywhere-opensource-src-5.7.0.tar.xz
修改qmake.conf文件
cd qt-everywhere-opensource-src-5.9.5/qtbase/mkspecs/linux-arm-gnueabi-g++/
vi qmake.conf
修改内容交叉编译器,最好以绝对路径的方式写入
# # qmake configuration for building with arm-linux-gnueabi-g++ # MAKEFILE_GENERATOR = UNIX CONFIG += incremental QMAKE_INCREMENTAL_STYLE = sublib QT_QPA_DEFAULT_PLATFORM = linuxfb QMAKE_CFLAGS_RELEASE += -O2 -march=armv7-a QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv7-a include(../common/linux.conf) include(../common/gcc-base-unix.conf) include(../common/g++-unix.conf) # modifications to g++.conf QMAKE_CC = /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-gcc QMAKE_CXX = /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-g++ QMAKE_LINK = /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-g++ QMAKE_LINK_SHLIB = /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-g++ # modifications to linux.conf QMAKE_AR = /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-ar cqs QMAKE_OBJCOPY = /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-objcopy QMAKE_NM = /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-nm -P QMAKE_STRIP = /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-strip load(qt_config) |
回到源码根目录,执行配置,生成Makefile文件
./configure -v -prefix /home/cheng/qtworks/qt5/install -opensource -release -xplatform linux-arm-gnueabi-g++ -no-opengl -no-dbus -no-icu -no-eglfs -no-iconv -skip qtpurchasing -skip qt3d -skip qtcanvas3d -skip qtdeclarative -I/home/cheng/qtworks/tslib/install/include -L/home/cheng/qtworks/tslib/install/lib |
参数说明
-prefix 安装路径
-xplatform 交叉编译器
-I 触摸校准头文件路径
-L 触摸校准库路径
配置过程会提示输入yes等
编译
make -j4
安装
make install
新建脚本,设置环境变量
vim setARMenv.sh
内容
#!/bin/sh export QTEDIR=/home/cheng/qtworks/qt5/install:$QTEDIR export PATH=/home/cheng/qtworks/qt5/install/bin:$PATH export LD_LIBRARY_PATH=/home/cheng/qtworks/qt5/install/lib: LD_LIBRARY_PATH export QMAKESPEC=/home/cheng/qtworks/qt5/qt-everywhere-opensource-src-5.7.0/qtbase/mkspecs/linux-arm-gnueabi-g++ |
设置脚本运行权限
chmod +x setARMenv.sh
执行新环境变量,对当前用户生效,重启后时效,需要重新运行
source setARMenv.sh
#!/bin/sh export QTEDIR=/home/cheng/qtworks/qt5/install:$QTEDIR export PATH=/home/cheng/qtworks/qt5/install/bin:$PATH export LD_LIBRARY_PATH=/home/cheng/qtworks/qt5/install/lib: LD_LIBRARY_PATH export QMAKESPEC=/home/cheng/qtworks/qt5/qt-everywhere-opensource-src-5.7.0/qtbase/mkspecs/linux-arm-gnueabi-g++ |
查看qmake版本
用编译后qmake编译qt工程,查看文件属性(或查看example里面的例程),显示为ARM,则交叉编译成功
进入到交叉编译好的QT库,将/include /lib /plugins 三个文件夹拷贝至arm linux最小根文件系统的opt目录
拷贝交叉编译器相关lib到arm linux最小根文件系统的/lib目录
sudo cp -r /usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/lib/*so* ./lib/ -d
sudo cp -r /usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/usr/lib/*so* ./lib/ -d
配置最小系统/etc/profile环境变量文件
vi /etc/profile
# Ash profile # vim: syntax=sh # No core files by default ulimit -S -c 0 > /dev/null 2>&1 USER=”`id -un`” LOGNAME=$USER PS1='[$USER@$HOSTNAME]# ‘ PATH=$PATH HOSTNAME=`/bin/hostname` export USER LOGNAME PS1 PATH #lib export LD_LIBRARY_PATH=/lib:/usr/lib:$LD_LIBRARY_PATH # tslib export TSLIB_ROOT=/usr/local/tslib export TSLIB_CONSOLEDEVICE=none export TSLIB_FBDEVICE=/dev/fb0 export TSLIB_TSDEVICE=/dev/input/event2 export TSLIB_TSEVENTTYPE=input export LD_LIBRARY_PATH=$TSLIB_ROOT/lib:$LD_LIBRARY_PATH export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf export TSLIB_CALIBFILE=/etc/pointercal # Qt export QT_ROOT=/opt/Qt5.7.0 export LD_LIBRARY_PATH=$QT_ROOT/plugins/imageformats/:$QT_ROOT/lib:$LD_LIBRARY_PATH export QT_QPA_GENERIC_PLUGINS=tslib export QT_QPA_FONTDIR=$QT_ROOT/lib/fonts export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_ROOT/plugins export QT_QPA_PLATFORM=linuxfb:tty=/dev/fb0 export QWS_MOUSE_PROTO=’Tslib:/dev/input/event2 MouseMan:/dev/input/mice’ export PATH=/bin:/sbin:/usr/bin/:/usr/sbin if [ -e /etc/pointercal ] ; then fsize=$(/bin/ls -al /etc/pointercal | cut -d’ ‘ -f 5) echo $fsize if [ $fsize -ge “1” ]; then echo “/etc/pointercal is exit” else echo “/etc/pointercal is empty” rm /etc/pointercal /usr/local/tslib/bin/ts_calibrate fi else echo “/etc/pointercal not found” /usr/local/tslib/bin/ts_calibrate fi FB_SIZE=$(cat /sys/class/graphics/fb0/virtual_size) case “$FB_SIZE” in 1024,1536) export QWS_DISPLAY=”LinuxFb:mmWidth91:mmHeight53:1″ echo -e “\n———–>lcd is 9.7” export QWS_SIZE=1024×768 ;; 800,2560) export QWS_DISPLAY=”LinuxFb:mmWidth91:mmHeight53:1″ echo -e “\n———–>lcd is 7.0” export QWS_SIZE=1280*800 ;; 480,544) export QWS_DISPLAY=”LinuxFb:mmWidth91:mmHeight53:1″ echo -e “\n———–>lcd is 4.3” export QWS_SIZE=480*272 esac #export QWS_DISPLAY=”LinuxFb:mmWidth91:mmHeight53:1″ #lcd can be set Rot0 Rot90 Rot180 Rot270 export QWS_DISPLAY=Transformed:Rot90 export HOME=/root |
完成后,返回根文件系统上一层路径,执行命令,生成根文件系统镜像
make_ext4fs -s -l 996147200 -a root -L linux system.img system
重新镜像烧写
fastboot.exe flash system system.img
fastboot -w
fastboot reboot
开发板接入屏幕,正常开机后会执行屏幕校准,并在/etc/目录下生成一个校准数据文件/etc/pointercal
串口进入linux开发板,拷贝交叉编译的QT例程到开发板,运行后,屏幕上能正常运行例程,则QT交叉编译成功。
如果文章对您有帮助,欢迎移至上方按钮打赏博主;
在make install的时候出现了问题:
qpaintervideosurface.cpp: In function ‘void makeCurrent(QGLContext*)’:
qpaintervideosurface.cpp:67:12: error: invalid use of incomplete type ‘class QGLContext’
context->makeCurrent();//
^~
In file included from /home/snac/qt-everywhere-src-5.12.4/qtbase/include/QtWidgets/qwidget.h:1:0,
from /home/snac/qt-everywhere-src-5.12.4/qtbase/include/QtWidgets/../../src/widgets/widgets/qabstractbutton.h:46,
from /home/snac/qt-everywhere-src-5.12.4/qtbase/include/QtWidgets/qabstractbutton.h:1,
from /home/snac/qt-everywhere-src-5.12.4/qtbase/include/QtWidgets/QtWidgets:6,
from ../../include/QtMultimediaWidgets/QtMultimediaWidgetsDepends:6:
/home/snac/qt-everywhere-src-5.12.4/qtbase/include/QtWidgets/../../src/widgets/kernel/qwidget.h:703:18: note: forward declaration of ‘class QGLContext’
friend class QGLContext;
^~~~~~~~~~
qpaintervideosurface.cpp:69:26: error: invalid use of incomplete type ‘class QGLContext’
auto handle = context->contextHandle();//
^~
In file included from /home/snac/qt-everywhere-src-5.12.4/qtbase/include/QtWidgets/qwidget.h:1:0,
from /home/snac/qt-everywhere-src-5.12.4/qtbase/include/QtWidgets/../../src/widgets/widgets/qabstractbutton.h:46,
from /home/snac/qt-everywhere-src-5.12.4/qtbase/include/QtWidgets/qabstractbutton.h:1,
from /home/snac/qt-everywhere-src-5.12.4/qtbase/include/QtWidgets/QtWidgets:6,
from ../../include/QtMultimediaWidgets/QtMultimediaWidgetsDepends:6:
/home/snac/qt-everywhere-src-5.12.4/qtbase/include/QtWidgets/../../src/widgets/kernel/qwidget.h:703:18: note: forward declaration of ‘class QGLContext’
friend class QGLContext;
^~~~~~~~~~
qpaintervideosurface.cpp:70:35: error: incomplete type ‘QOpenGLContext’ used in nested name specifier
if (handle && QOpenGLContext::currentContext() != handle)
^~~~~~~~~~~~~~
qpaintervideosurface.cpp: At global scope:
qpaintervideosurface.cpp:65:13: warning: ‘void makeCurrent(QGLContext*)’ defined but not used [-Wunused-function]
static void makeCurrent(QGLContext *context)
^~~~~~~~~~~
Makefile:4906: recipe for target '.obj/qpaintervideosurface.o' failed
make[3]: *** [.obj/qpaintervideosurface.o] Error 1
make[3]: Leaving directory '/home/snac/qt-everywhere-src-5.12.4/qtmultimedia/src/multimediawidgets'
Makefile:85: recipe for target 'sub-multimediawidgets-install_subtargets' failed
make[2]: *** [sub-multimediawidgets-install_subtargets] Error 2
make[2]: Leaving directory '/home/snac/qt-everywhere-src-5.12.4/qtmultimedia/src'
Makefile:60: recipe for target 'sub-src-install_subtargets' failed
make[1]: *** [sub-src-install_subtargets] Error 2
make[1]: Leaving directory '/home/snac/qt-everywhere-src-5.12.4/qtmultimedia'
Makefile:589: recipe for target 'module-qtmultimedia-install_subtargets' failed
make: *** [module-qtmultimedia-install_subtargets] Error 2
请问各位大佬这是什么问题,
用configure配置的安装路径出错了?编译正常吗?
老大, 想请教一下...我再jetson nano开发的qt软件,, 在桌面上能跑起来..但我不想启动我的桌面,而是直接启动我的软件(这样省掉桌面的CPU资源), 所以我再init 3下想启动的软件. 但没办法直接启动...我用方法1: startx ./xxx 我的软件.这样就可以启动了. 但是我的摄像头播放的视频渲染会有格子的东西(在桌面运行不会); 方法2: /etc/profix 加入我的软件路径开机启动..但还是渲染出现格子的问题...是我这样的启动方式出问题了吗???还是我这种开发不算是嵌入式?
博主你好呀 我安装tslib遇到 configure:error:in /opt/tslib-1.4
configure: error :C compiler cannot create executables
这是什么问题呀