This article introduces how to configure the Qt runtime environment on an embedded Linux development board and perform Qt program running tests.
1 Compiling tslib
I have previously used tslib for testing the touchscreen, so I will record the compilation process here.
Download the source code of the tslib library: https://github.com/libts/tslib/tags
Copy the downloaded source code to the Ubuntu virtual machine and then extract:
tar xvf tslib-1.21.tar.bz2
When compiling tslib, you need to install some files in Ubuntu first:
sudo apt-get install autoconf
sudo apt-get install automake
sudo apt-get install libtool
Create a directory named “tslib” in Ubuntu to store the compilation results, then execute the following commands to compile:
./configure --host=arm-linux-gnueabihf ac_cv_func_malloc_0_nonnull=yes --cache-file=arm-linux.cache -prefix=/home/xxpcb/myTest/imx6ull/otherlib/tslib-2/tslib
make
make install
After compilation, make install will copy the compiled results to the specified tslib directory:

First, package the entire tslib folder into arm-tslib.tar.bz2 file, which will be used for later porting to the development board:
tar -jcf arm-tslib.tar.bz2 tslib
2 Compiling Qt Source Code
2.1 Download Qt5 Source Code
Download link: https://download.qt.io/archive/qt/5.15/5.15.2/single/

Copy the downloaded qt-everywhere-src-5.15.2.tar.xz to Ubuntu and then extract:
tar -xvf qt-everywhere-src-5.15.2.tar.xz

2.2 Modify qmake.conf
Modify the qtbase/mkspecs/linux-arm-gnueabi-g++/ qmake.conf file
The default content of this file is:
#
# 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-gnueabi-gcc
QMAKE_CXX = arm-linux-gnueabi-g++
QMAKE_LINK = arm-linux-gnueabi-g++
QMAKE_LINK_SHLIB = arm-linux-gnueabi-g++
# modifications to linux.conf
QMAKE_AR = arm-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = arm-linux-gnueabi-objcopy
QMAKE_NM = arm-linux-gnueabi-nm -P
QMAKE_STRIP = arm-linux-gnueabi-strip
load(qt_config)
Modify it as follows:

2.3 Configure Compilation Options
Check the compilation options by entering ./configure -help command to see the configurable options
./configure -help

There are many configuration options, so you can use a configuration script to configure.
Create an autoconfigure.sh file and write the following configuration according to your situation:
./configure -prefix /home/xxpcb/myTest/imx6ull/otherlib/qt/qt-everywhere-src-5.12.9/arm-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/xxpcb/myTest/imx6ull/otherlib/tslib-2/tslib/include \
-L/home/xxpcb/myTest/imx6ull/otherlib/tslib-2/tslib/lib \
-recheck-all
Note that three places are your own configuration paths:
1 /home/xxpcb/myTest/imx6ull/otherlib/qt/qt-everywhere-src-5.12.9/arm-qt is the compilation output path.
2 /home/xxpcb/myTest/imx6ull/otherlib/tslib-2/tslib/include is the tslib header file path.
3 /home/xxpcb/myTest/imx6ull/otherlib/tslib-2/tslib/lib is the tslib related library file path.
Other parameters meanings:
-
-opensource: Build the open-source version of Qt
-
-release: Use the release version of Qt
-
-xplatform linux-arm-gnueabi-g++: Specify the compiler
-
-skip qt3d: Skip Qt 3D
-
-make libs: Compile the libraries to be used
-
-make examples: Compile the example codes of Qt
-
-nomake tools: Do not generate Qt tools
-
-no-openssl: Do not use OpenSSL
2.4 Compile
You need to install g++ before configuring
sudo apt-get install g++
Grant executable permissions to the script and then execute autoconfigure.sh
chmod +x autoconfigure.sh
./autoconfigure.sh

After running:

You can then run the make command to compile.
The compilation takes about a few to dozens of minutes.

After compilation, run make install to install, and you will see the contents in the arm-qt folder:

Package the entire qrm-qt folder into arm-qt.tar.bz2 file, which will be used for later porting to the development board:
tar -jcf arm-qt.tar.bz2 arm-qt
2.5 Compilation Error Issues
During make compilation, you may encounter compilation errors
-
Situation 1: I encountered the following:

This situation is because my Ubuntu virtual machine ran out of space; the solution is to expand the virtual machine, see: VirtualBox Ubuntu Virtual Machine Expansion Record for details.
-
Situation 2: Compilation of the latest version of Qt source code reports an error

Compiling with the latest version of Qt 5.15.2 reported an error, and I have not found a solution yet, so I used Qt version 5.12.9 instead.
3 Configuring Qt Environment on the Development Board
3.1 Copying tslib and Qt Compiled Files
Copy the previously packaged arm-tslib.tar.bz2 and arm-qt.tar.bz2 compressed packages to the board, you can first copy them to the NFS network location, then extract them to the /usr/lib directory, and delete the useless compressed packages after extraction.
Here are the operation steps for arm-qt:
cp arm-qt.tar.bz2 ~/myTest/nfs/rootfs/usr/lib
cd ~/myTest/nfs/rootfs/usr/lib/
tar xf arm-qt.tar.bz2
rm arm-qt.tar.bz2
The copying and extraction process for arm-tslib is similar.
3.2 Setting Environment Variables on the Development Board
Edit /etc/profile and write the following content:
export TSLIB_ROOT=/usr/lib/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/lib/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
Then make this configuration take effect immediately:
source /etc/profile
4 Qt Running Test
The compiled files of Qt come with some examples that can be run on the board to check if the Qt program runs normally.
This is one of the programs being run:
/usr/lib/arm-qt/examples/widgets/animation/animatedtiles/animatedtiles
end
One Linux
Follow, reply 【1024】massive Linux materials to give away
Collection of Wonderful Articles
Article Recommendations
Click “Read Original” for more shares, welcome to share, collect, like, and view