1. 导入交叉编译器路径加入PATH
export PATH=$PATH:/opt/ext-toolchain/bin/
我的交叉编译工具链放在 /opt/ext-toolchain下
ls /opt/ext-toolchain
arm-linux-gnueabihf bin gcc-linaro-5.3.1-2016.05-linux-manifest.txt include lib libexec share
ls /opt/ext-toolchain/bin
arm-linux-gnueabihf-addr2line arm-linux-gnueabihf-cpp arm-linux-gnueabihf-gcc-ar arm-linux-gnueabihf-gdb arm-linux-gnueabihf-nm arm-linux-gnueabihf-size
arm-linux-gnueabihf-ar arm-linux-gnueabihf-elfedit arm-linux-gnueabihf-gcc-nm arm-linux-gnueabihf-gfortran arm-linux-gnueabihf-objcopy arm-linux-gnueabihf-strings
arm-linux-gnueabihf-as arm-linux-gnueabihf-g++ arm-linux-gnueabihf-gcc-ranlib arm-linux-gnueabihf-gprof arm-linux-gnueabihf-objdump arm-linux-gnueabihf-strip
arm-linux-gnueabihf-c++ arm-linux-gnueabihf-gcc arm-linux-gnueabihf-gcov arm-linux-gnueabihf-ld arm-linux-gnueabihf-ranlib gdbserver
arm-linux-gnueabihf-c++filt arm-linux-gnueabihf-gcc-5.3.1 arm-linux-gnueabihf-gcov-tool arm-linux-gnueabihf-ld.bfd arm-linux-gnueabihf-readelf runtest
可以看到交叉编译使用的 arm-linux-gnueabihf-g++ 在这个目录下
2. 下载解压qt源码
官网下载地址:
中科大镜像下载地址:
https://mirrors.ustc.edu.cn/qtproject/archive/qt/5.15/5.15.10/single/
3. 配置QT编译选项
build.sh
./qt-everywhere-src-5.15.10/configure \
-xplatform linux-arm-gnueabi-g++ \
-prefix ./qt-5.15.10 \
-opensource \
-confirm-license \
-release \
-strip \
-shared \
-optimized-qmake \
-c++std c++11 \
-no-pch \
-skip qt3d \
-skip qtandroidextras \
-skip qtconnectivity \
-skip qtdoc \
-skip qtgamepad \
-skip qtlocation \
-skip qtmacextras \
-skip qtnetworkauth \
-skip qtpurchasing \
-skip qtremoteobjects \
-skip qtscript \
-skip qtscxml \
-skip qtsensors \
-skip qtspeech \
-skip qtsvg \
-skip qttools \
-skip qttranslations \
-skip qtwayland \
-skip qtwebengine \
-skip qtwebview \
-skip qtwinextras \
-skip qtx11extras \
-skip qtxmlpatterns \
-make libs \
-make examples \
-nomake tools -nomake tests \
-gui \
-widgets \
-dbus-runtime \
--glib=no \
--iconv=no \
--pcre=qt \
--zlib=qt \
-no-openssl \
--freetype=qt \
--harfbuzz=qt \
-no-opengl \
-linuxfb \
--xcb=no \
--libpng=qt \
--libjpeg=qt \
--sqlite=qt \
-plugin-sql-sqlite \
-recheck-all
执行完成后会生成很多makefile
可以看到 我们的编译去使用的是armhf的,但是配置脚本指定的是linux-arm-gnueabi-g++,因此需要适配
qt-everywhere-src-5.15.10/qtbase/mkspecs/linux-arm-gnueabi-g++$ cat 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 = arm-linux-gnueabihf-gcc
QMAKE_CXX = arm-linux-gnueabihf-g++
QMAKE_LINK = arm-linux-gnueabihf-g++
QMAKE_LINK_SHLIB = arm-linux-gnueabihf-g++
# modifications to linux.conf
QMAKE_AR = arm-linux-gnueabihf-ar cqs
QMAKE_OBJCOPY = arm-linux-gnueabihf-objcopy
QMAKE_NM = arm-linux-gnueabihf-nm -P
QMAKE_STRIP = arm-linux-gnueabihf-strip
load(qt_config)
就是将其中的arm-linux-gnueabi-g++ 改为 arm-linux-gnueabihf-g++
4. 执行编译
make
编译完成后,生成的代码会放到 qtbase目录下
5. 将编译好的QT部署到执行环境中
我将qtbase放到了执行环境的 /usr/loca/qt5.15.10下
QT触摸插件tslib自行编译
6. 在执行环境中配置QT环境变量-使用linuxfb进行渲染/使用触摸屏tslib
#!/bin/sh
#export QT_DEBUG_PLUGINS=1 # 调试加载LOG
export QT_HOME=/usr/local/qt5.15.10/ # Qt库路径
export QT_QPA_FB_DRM=1 # 启用FB_DRM
#export QT_QPA_GENERIC_PLUGINS=evdevkeyboard # 启用键盘插件
#export QT_QPA_GENERIC_PLUGINS=evdevmouse # 启用鼠标插件
#export QT_QPA_EVDEV_MOUSE_PARAMETERS=/dev/input/event0 # 鼠标设备
#export QT_QPA_EVDEV_KEYBOARD_PARAMETERS=/dev/input/event1 # 键盘设备
export QT_QPA_FONTDIR=$QT_HOME/lib/fonts # 字体路径
export QT_PLUGIN_PATH=$QT_HOME/plugins # 插件路径
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0 # fb设备
export QT_QPA_FONTDIR=/usr/local/wqy-zenhei/
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_ROOT=/usr/local/tslib
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/input/event4
export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf
export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts
export TSLIB_CALIBFILE=$TSLIB_ROOT/etc/pointercal
export QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/event4
export QT_QPA_PLUGINS=1
export QT_QPA_FB_TSLIB=1
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$QT_HOME/lib:$TSLIB_ROOT/lib" # 库路径
export PATH=$TSLIB_ROOT/bin:$PATH
ts_test #执行触摸屏测试程序
标签:10,qt5.15,QT5,QT,skip,gnueabihf,export,linux,arm From: https://www.cnblogs.com/riveruns/p/17716614.html