Trucrux Inc

Building a Qt Application

In order to build Qt applications targeted for the embedded Yocto image, we need to have a full Qt toolchain which provides (besides cross GCC and GDB) the Qt headers to include and libraries to link against

Qt5 Toolchain installation #

Before installing toolchain, first need to follow Building TruxOS from Source Code.

Build Toolchain #
$ cd ~/CodeSetup
$ MACHINE=imx8mq-trux-q01 DISTRO=fslc-xwayland . setup-environment build_xwayland
$ bitbake meta-toolchain-qt5

The output will be located at tmp/deploy/sdk/

Install Toolchain #

Install the tools by running

$ tmp/deploy/sdk/fslc-xwayland-glibc-x86_64-fsl-image-qt5-aarch64-imx8mq-trux-q01-toolchain-3.1.sh

Reply to all defaults ‘y’
At the end of the installation you should see the following:

SDK has been successfully set up and is ready to be used.
Use Toolchain #

Each time you wish to use the toolchain in a new shell session, you need to source the environment setup script:

$ source /opt/fslc-xwayland/3.1/environment-setup-aarch64-fslc-linux

Yocto Qt Creator Guide #

Please note that for each Qt5 version a minimum Qt Creator version is required

Yocto QT5 QtCreator (minimum suggested version)
Fido 5.4 3.3.1
Jethro 5.5 3.3.1
Krogoth 5.6 3.5.1
Morty 5.7 3.5.1
Pyro 5.8 3.5.1
Rocko 5.9 4.5.2
Sumo 5.10 4.5.2
Thud 5.11 4.5.2
Zeus 5.13 4.5.2
Dunfell 5.14 4.5.2

For previous Ubuntu versions the Ubuntu SDK team periodically provide QtCreator backporting for LTS releases and currently provide version 4.1.0, enough up to Yocto Pyro.

For Ubuntu 16.04, from Yocto Rocko on, official QtCreator is required.

For Ubuntu 18.04 and 20.04, the stock QtCreator from Ubuntu repositories should be enough.

Qt Creator Installation #

for Ubuntu 18.04 and newer

$ sudo apt install qtcreator
QtCreator configuration #
$ source /opt/fslc-xwayland/3.1/environment-setup-aarch64-fslc-linux\
$ qtcreator
Device configuration #
  • Go to Tools => Options.
  • In the left panel, click on Devices
  • Add a new device representing the target “mydevice”:
  • Press Add and choose Generic Linux Device
  • Specify a name (e.g. mydevice)
  • Fill in the device’s IP address.
    Please consider using fixed IP adresses: DHCP server lease timeout could lead to unreachable devices.
  • Authentication on our modules by default: Password, User “root”, empty password
Debugger configuration #
  • Go to Tools => Options
  • In the left panel, click on Kits.
  • Click on the Debuggers tab
  • Press Add
  • Specify a name (e.g. mydevice GDB)
  • Specify the path: /opt/fslc-xwayland/3.1/sysroots/x86_64-fslcsdk-linux/usr/bin/aarch64-fslc-linux/aarch64-fslc-linux-gdb
GCC Compiler configuration #
  • Go to Tools => Options
  • In the left panel, click on Kits.
  • Click on the Compilers tab
  • Press Add
  • Specify a name (e.g. mydevice GCC)
  • Specify the path: /opt/fslc-xwayland/3.1/sysroots/x86_64-fslcsdk-linux/usr/bin/aarch64-fslc-linux/aarch64-fslc-linux-gcc
G++ Compiler configuration (only for QtCreator > 4.1) #
  • Go to Tools => Options
  • In the left panel, click on Kits.
  • Click on the Compilers tab
  • Press Add
  • Specify a name (e.g. mydevice G++)
  • Specify the path: /opt/fslc-xwayland/3.1/sysroots/x86_64-fslcsdk-linux/usr/bin/aarch64-fslc-linux/aarch64-fslc-linux-g++
CMAKE configuration (only for QtCreator > 4.1) #
  • Go to Tools => Options
  • In the left panel, click on Kits.
  • Click on the CMake tab
  • Press Add
  • Specify a name (e.g. mydevice CMake)
  • Specify the path: /opt/fslc-xwayland/3.1/sysroots/x86_64-fslcsdk-linux/usr/bin/cmake
Qt version configuration #
  • Go to Tools => Options
  • In the left panel, click on Kits.
  • Click on the Qt Version tab
  • Press Add
  • Specify a name (e.g. mydevice Qt 5.x)
  • Specify the path: /opt/fslc-xwayland/3.1/sysroots/x86_64-fslcsdk-linux/usr/bin/qmake
Kit configuration #
  • Go to Tools => Options
  • In the left panel, Click on Kits tab
  • Press Add
  • Name: mydevice
  • Device: mydevice
  • Sysroot: /opt/fslc-xwayland/3.1/sysroots/aarch64-fslc-linux
  • Compiler: mydevice GCC
  • Debugger: mydevice GDB
  • Qt version: mydevice Qt 5.x
  • Qt mkspec: leave empty or set to linux-oe-g++ if cross-compilation fails