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 used tslib previously for testing the touchscreen, and here I will record the compilation process.
Download the source code of tslib library: https://github.com/libts/tslib/tags
Copy the downloaded source code to the Ubuntu virtual machine, then extract:
tar xvf tslib-1.21.tar.bz2
Before compiling tslib, you need to install some files in Ubuntu:
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 compilation results to the specified tslib directory:

Package the tslib folder into arm-tslib.tar.bz2 file for later use when porting to the development board:
tar -jcf arm-tslib.tar.bz2 tslib
2 Compiling Qt Source Code
2.1 Downloading 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, then extract:
tar -xvf qt-everywhere-src-5.15.2.tar.xz

2.2 Modifying 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 to the following:

2.3 Configuring Compilation Options
Check the compilation options by entering ./configure -help command:
./configure -help

There are many configuration options, so a configuration script can be used.
Create an autoconfigure.sh file and write the following configuration based on 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 paths are your own configurations:
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 path to the tslib header files.
3 /home/xxpcb/myTest/imx6ull/otherlib/tslib-2/tslib/lib is the path to the tslib related library files.
Other parameter 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’s 3D module
-
-make libs: Compile the libraries needed
-
-make examples: Compile the example codes of Qt
-
-nomake tools: Do not generate Qt tools
-
-no-openssl: Do not use OpenSSL
2.4 Compilation
Before configuration, you need to install g++
sudo apt-get install g++
Grant executable permissions to the script, then execute autoconfigure.sh
chmod +x autoconfigure.sh
./autoconfigure.sh

After running:

You can then execute make to start the compilation.
The compilation takes about ten to several dozen minutes.

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

Package the qrm-qt folder into arm-qt.tar.bz2 file for later use when porting to the development board:
tar -jcf arm-qt.tar.bz2 arm-qt
2.5 Compilation Errors
You may encounter compilation errors during make
-
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 Expansion Record for specific operations.
-
Situation 2: Compilation error when compiling the latest version of Qt source code

Compilation error when using the latest version 5.15.2 of Qt, a solution has not yet been found, so I used version 5.12.9 of Qt.
3 Configuring Qt Environment on Development Board
3.1 Copying tslib and Qt Compilation Files
Copy the previously packaged arm-tslib.tar.bz2 and arm-qt.tar.bz2 compressed packages to the board, you can first copy to the nfs network location, then extract to the /usr/lib directory, and delete the useless compressed packages after extraction.
Here are the 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, 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
In the compiled Qt files, there are some examples that come with Qt, you can run these examples on the board to see if the Qt program can run normally.
This is how to run one of the programs:
/usr/lib/arm-qt/examples/widgets/animation/animatedtiles/animatedtiles