Using Qt cross toolchain and QtCreator

By using a cross toolchain on your development computer, you can easily create Qt5 or bare C/C++ applications to run on your Kontron hardware. This is the fastest way to get your application run on your target device. With this setup you are not bound to the yocto workflow. After you have developed your application, you can integrate it into your own yocto layer to deploy your application with your image.

Setting up the toolchain

To be able to compile for your target system you must have the appropriate SDK for your system installed. See Building the SDK for your image for more information on how to do that.


The version of the SDK should match the firmware version which runs on your device.

Setting up Qt/QtCreator

Installing Qt/QtCreator

Check the download page for the latest release of QtCreator and download the

Install QtCreator by double-clicking the *.run-file in the file-manager or by running

chmod +x

Alternatively you might also want to consider installing the full Qt environment for your desktop, including sources, tools and QtCreator. The advantage is, that apart from the Yocto-based target toolchain, you also have a toolchain available for your desktop environment. This enables you to switch between deploying to the target and deploying to your desktop machine for testing.

The online installer for the latest OpenSource edition of Qt can be found here for x86_64 bit linux systems:

Starting QtCreator

To run QtCreator with the Kontron cross environment for your board you have to source the yocto environment before starting the QtCreator.

This can be accomplished thru different ways:

  1. Manual sourcing of the yocto environment setup script and starting QtCreator on command line
  2. Using Kontrons script

The simplest way is using script which can be found in Kontrons VMware image.

Manual sourcing

Open a shell and source the yocto environment script, then start QtCreator:

source /opt/kontron/stm32mp-t1000-s-multi/thud_1.3.1/environment-setup-cortexa7t2hf-neon-vfpv4-ktn-linux-gnueabi

Using script

You can find the script in Kontrons VMware image at /home/user/Qt/Tools/QtCreator/bin/

After launching you can choose the toolchain you want to use. Choosing 'Cancel' doesn't source any yocto environment script.

Setting up your kit

For compiling and debugging you need an appropriate so called 'kit' for your device. This kit provides all information needed for debugging with your hardware like

  • cross toolchain
  • debugger binary
  • debug symbols and headers for the libraries the target uses (sysroot)

Kontron suggests to use one of the provided kits for the demo boards. If your have to modify one of the kits or you want to create your own kit, these kits are a good starting point.

Kits can be modified in the Kits view (Tools -> Options -> Kits). Here you can configure your kit with:

  • its name (choose what you want)
  • the device type (only Generic Linux Device for Kontron devices)
  • the device to be used (see also Adding your own device)
  • the sysroot - headers and libraries for the Yocto firmware (toolchain base directory/sysroots/cortex*)
  • c cross-compiler (toolchain base directory/sysroots/x86*/usr/bin/arm-*-linux/arm-*-gcc)
  • c++ cross-compiler (toolchain base directory/sysroots/x86*/usr/bin/arm-*-linux/arm-*-g++)
  • cross-debugger (/usr/bin/gdb-multiarch)
  • Qt version (toolchain base directory/sysroots/x86*/usr/bin/qt5/qmake)

The configuration entries for compiler, debugger and Qt version have several tabs to enter the matching configuration settings. In the kits view you can only select already pre-defined settings.

Adding your own device

To be able to use the deploy and debugging features within QtCreator with your own device you can modify an existing configuration or create a new one.

If you want to create a new configuration in QtCreator or modify an existing one go to Tools -> Options -> Devices and add your device by clicking Add .... Choose Generic Linux Device from the drop down menu. Set the appropriate values for the device name, ip address and the username and password. The connection can be tested with the Test button in the devices tab.

Deploying to the target

If you are using a development environment provided by Kontron, and you are running a build of a demo image on your hardware (includes ssh-server, sftp-server, gdbserver), you should be able to deploy your app to the target via network. To change the settings of the remote device (IP-Adress, ...) in QtCreator, go to Tools -> Options -> Devices -> Kontron stm32mp DemoKit.
QtCreator uses sftp and ssh to copy the files and run the application remotely.

The deployment of your files is configured in your qmake project file by setting the INSTALLS variable. The Kontron demo programs contain some simple deployment rules. For more information see the Qt/qmake documentation.


Before starting your own Qt application on the device, you have to stop any already running Qt applications! If e.g. the kontron-demo application is running on the device you can simple do a killall kontron-demo command to stop this application.

Copy files manually to the target

Using the protocols sftp and scp files can be copied to the target. If the target has the IP address the content of the target can be shown by using the URL sftp://root@ in a browser window.
To copy files via command line the program scp can be used.
You can also start a remote shell on the target via ssh:

user@ubuntu:~$  ssh root@

Qt environment

Qt offers several options concerning framebuffer, eglfs, input devices, etc. that can be set via environment variables.
Please use this page as a reference for the available options: Qt for Embedded Linux

QML software rendering

To be able to use QML/QtQuick applications on SoCs without GPU, or if you don't want to use the proprietary hardware acceleration libraries it is possible to select the included software renderer. Some features such as shaders, etc. won't be available and you might experience performance issues, depending on how your application is designed.

To use the software backend, set QT_QPA_PLATFORM=linuxfb and QT_QUICK_BACKEND=software in your environment. The full environment for Kontron 5 inch Demo-Kit for example:


QML accelerated rendering

For accelerated rendering of QML/QtQuick applications on GPU these settings are used for Kontron 5 inch Demo-Kit:



The current revision of the OpenGL library doesn't play well with Qt. In most cases using software rendering for QML/QtQuick applications leads to a more responsive UI experience.


If gdbserver is running on the target (default in Kontrons demo images) you should be able to use the debugging features in QtCreator.

If you want to debug QML based applicaitons ensure, that (QML-)debugging is enabled in the project settings. If you are trying to debug a QML application and you get an error message "Invalid Signal", then try to skip the message by clicking 'OK' and the use the button with the green arrow to continue debugging.

Further hints for debugging

  • Disable optimization
    Debugging an optimized binary might be difficult because the compiler may reorder or optimize away some code. To disable optimization for debugging purposes you can set some QMAKE variables in your project file to disable optimization. But be aware that this might lead to differnt timings for your applicaiton!
  • Rejected loading of shared libraries
    Loading of shared libraries is sometimes rejected by gdb due to 'insecure path settings'. Put these gdb commands into your QtCreator configuration for gdb to disable secure path setting. set auto-load safe-path / You can configure additional start commands for gdb thru Tools -> Options -> Debugger -> GDB.

  • Using gdb-multiarch
    Qt Creator uses so called pretty printers to provide a easy interface to basic Qt classes like e.g. Qt strings. These pretty printers are implemented with the help of python functions in gdb. The cross toolchain for the devices may lack some python libraries Qt creator needs for its pretty printers. To circumvent this use the gdb-mulitarch debugger of your development machine for remote debugging. You can install gdb-multiarch on your development host by running sudo apt install gdb-multiarch.

Creating a Yocto recipe for a Qt application

To build your Qt application with bitbake and include it in a Yocto image, you have to create a recipe similar to the following example. Create it as in your custom layer meta-customer/recipes-customer/your-app/. The example fetches the sources from a GIT repository. Instead of that, the sources can also be fetched from local files in the recipe directory, from a tarball or a SVN server. See the Yocto-Dev-Manual for more information on how to write your own recipe.

SUMMARY = "The Qt5 Demo QML Application for the Kontron DevKit"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.GPLv2;md5=751419260aa954499f7abaabaa882bbe"

# Use qmake
inherit qmake5


# Build Dependencies
DEPENDS += "qtbase qtdeclarative qtmultimedia"

# Runtime Dependencies for the kontron-demo package
RDEPENDS_${PN} += "qtmultimedia-qmlplugins qtmultimedia-plugins \
           gst-plugins-base-meta gst-fsl-plugin \
           gst-plugins-good-meta gst-plugins-bad-meta \
           qtdeclarative-qmlplugins qtbase-plugins qtbase-fonts"

# Specify the path to the source files
S = "${WORKDIR}/git"

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

# Fetch the latest version from the master branch of the GIT repo
SRCBRANCH = "master"

# Where to fetch the sources from
SRC_URI = "git://${EXCEET_GIT_APPS}/exceet-demo.git;protocol=ssh;branch=${SRCBRANCH}"
SRC_URI_http = "git://${EXCEET_GIT_APPS}/exceet-demo.git;protocol=http;user=exceet-user:user;branch=${SRCBRANCH}"

# Which files to include in the kontron-demo package
FILES_${PN} = "/opt/exceet_demo_qml/* \
           /usr/src/debug/exceet-demo/* \
           /usr/bin/exceet_demo_qml \

# Which files to include in the exceet-demo-dbg package
FILES_${PN}-dbg = "/opt/exceet_demo_qml/.debug* \