在开发板中运行QT程序的基本条件是具备QT环境,那么QT的移植尤为重要,接下载我将和小伙伴们一起学习QT的移植。
tar vxf tslib-1.21.tar.bz2 cd tslib-1.21
sudo apt-get update sudo apt-get install autoconf automake libtool
./autogen.sh
./configure --host=arm-linux-gnueabihf ac_cv_func_malloc_0_nonnull=yes --cache-file=arm-linux.cache -prefix=/home/tslib-1.21/arm-tslib
编译并安装
make make install
tar vxf qt-everywhere-src-5.12.9.tar.xz cd qt-everywhere-src-5.12.9
vi 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 QT_QPA_DEFAULT_PLATFORM = linuxfb QMAKE_CFLAGS += -O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon -mfloat-abi=hard QMAKE_CXXFLAGS += -O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon -mfloat-abi=hard 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)
./configure -help
查看可配置的选项,由于需要配置的选项比较多,所以新建一个脚本存放配置选项。vim autoconfigure.sh
文件中的配置内如如下所示:
./configure -prefix /home/linux/tool/qt-everywhere-src-5.12.9/arm-qt \ #个人的QT安装路径 -opensource \ -confirm-license \ -release \ -strip \ -shared \ -xplatform linux-arm-gnueabi-g++ \ -optimized-qmake \ -c++std c++11 \ --rpath=no \ -pch \ -skip qt3d \ -skip qtactiveqt \ -skip qtandroidextras \ -skip qtcanvas3d \ -skip qtconnectivity \ -skip qtdatavis3d \ -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 \ -tslib \ --libpng=qt \ --libjpeg=qt \ --sqlite=qt \ -plugin-sql-sqlite \ -I/home/tslib-1.21/arm-tslib/include \ #个人的tslib安装路径 -L/home/tslib-1.21/arm-tslib/lib \ -recheck-all
chmod +x autoconfigure.sh ./autoconfigure.sh
make -j 16 make install
export TSLIB_ROOT=/usr/local/arm-tslib export TSLIB_CONSOLEDEVICE=none export TSLIB_FBDEVICE=/dev/fb0 export TSLIB_TSDEVICE=/dev/input/event1 export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts export TSLIB_CALIBFILE=/etc/pointercal export LD_PRELOAD=$TSLIB_ROOT/lib/libts.so
export QT_ROOT=/usr/local/arm-qt export QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/event1 export QT_QPA_FONTDIR=/usr/share/fonts export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_ROOT/plugins export QT_QPA_PLATFORM=linuxfb:tty=/dev/fb0 export QT_PLUGIN_PATH=$QT_ROOT/plugins export LD_LIBRARY_PATH=$QT_ROOT/lib:$QT_ROOT/plugins/platforms export QML2_IMPORT_PATH=$QT_ROOT/qml export QT_QPA_FB_TSLIB=1
source /etc/profile
/usr/lib/arm-qt/examples/widgets/animation/animatedtiles/animatedtiles
自己测试的效果如下图示
此方法是适用于制作生成的根文件系统,如果是标准的ubuntu系统时,无需对QT进行移植,因为在ubuntu系统中自带QT的运行环境,直接ubuntu根文件系统的小伙伴可以在路径中'/usr/lib/arm-linux-gnueabihf'查看QT库是否存在。
ls libQt5*
在路径'/usr/lib/arm-linux-gnueabihf/qt5'中可以看到相关文件
tslib移植arm及使用:https://www.cnblogs.com/silencehuan/p/11207996.html
QT5.9移植:https://www.jianshu.com/p/de6b0bc7893c