Using the 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.
Setting up the SDK
To generate a toolchain/SDK that matches the target image, you can run the
populate_sdk task for your image. For example:
bitbake image-ktn-qt -c populate_sdk
There might also be a SDK installer available for your target platform on the. Kontron server at https://files.kontron-electronics.de.
If you created the toolchain-installer with Yocto, you can find it in the
The installer is a shell script, that can be executed like this:
The default installation path is
/opt/kontron/ if not specified otherwise.
Check the download page at
for the latest release of QtCreator and download the
Install QtCreator by double-clicking the
*.run file in the file-manager or by
chmod +x qt-creator-opensource-linux-x86_64-4.11.2.run ./qt-creator-opensource-linux-x86_64-4.11.2.run
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.
Configuring and using QtCreator
For cross development using the Yocto SDK/toolchain, you need to pass the build environment settings to QtCreator. There are two ways to do this.
Using the helper script (only available in i.MX BSP from version 3.0 on)
The latest versions of the Kontron Yocto Qt SDKs provide a script, that creates the "Kit" with all the settings within QtCreator. It also copies the build environment variables to the Kit, so you can easily switch between different SDKs from within QtCreator and you don't need to source the build environment before starting QtCreator.
The script can be found in the SDK directory which defaults to
./qtcreator-setup-helper-armv7vet2hf-neon-ktnsdk-linux Please enter the path of your QtCreator installation or press enter for default (~/Qt/Tools/QtCreator): Using default path ~/Qt/Tools/QtCreator Created toolchain/compiler with id 'ProjectExplorer.ToolChain.Gcc:ktn-zeus-kontron-mx6ul' Created debugger with id 'ktn-zeus-kontron-mx6ul' Created Qt version with id 'ktn-zeus-kontron-mx6ul' Created kit with id 'ktn-zeus-kontron-mx6ul'
Running QtCreator within the build environment
To set the build environment for QtCreator manually you can edit the start
Add the following line at the very beginning of the file (before
and change the SDK path and script name accordingly:
This will source the build environment upon starting QtCreator. Please ensure, that you are always starting QtCreator through the qtcreator.sh script, and not directly by executing the binary.
You can modify the Ubuntu Launcher icon to make this easier. On Ubuntu 18.04 this should work:
The modification is to add
bash -c and an additional
.sh to the content of
Exec variable, so that after clicking on the symbol the script is called:
Exec="bash -c /home/Qt/Tools/QtCreator/bin/qtcreator.sh" %F
Configuring the SDK Kit
Kits can be modified in the Build&Run view (
Tools -> Options -> Build &
Run). Here you can configure your kit with:
- its name (choose what you want)
- the device type (Generic Linux Device for Kontron devices)
- the device to be used (see Adding your own device)
- the sysroot - headers and libraries for the Yocto firmware
- cross-compiler (
- cross-debugger (
- Qt version (
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 predefined settings.
Deploying to the target
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
Tools -> Options -> Devices and add your device by clicking
Generic Linux Device from the drop down menu. Set the appropriate
values for the device name, IP address and the username and password (if any).
The connection can be tested with the
Test button in the devices tab.
Deploy to the target device
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
INSTALLS variable. The Kontron demo programs contain some simple
deployment rules. For more information see the Qt/qmake
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
192.168.0.10 the content of the target can be shown
by using the URL
sftp://firstname.lastname@example.org/ 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:
ssh email@example.com firstname.lastname@example.org:~
If gdbserver is running on the target (default in image-exceet/image-ktn) you should be able to use the remote 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-app 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
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 have side effects!
QMAKE_CXXFLAGS_DEBUG += -O0 QMAKE_CFLAGS_DEBUG += -O0
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 through
Tools -> Options ->
Debugger -> GDB.
Using gdb-multarch (applies to Yocto Morty)
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 (already default for morty). You can install
gdb-multiarch on your
development host by running
sudo apt install gdb-multiarch.
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.
Also check the specific documentation for your platform/BSP, as it may contain further details for setting up Qt for your device.
QML Software Rendering
To be able to use QML/QtQuick applications on SoCs without GPU, it is possible to select the included software renderer. This enables you to use QML/QtQuick for example on our SoMs with i.MX6UL/ULL. 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_QUICK_BACKEND=software in your environment.
Creating a Yocto recipe for a Qt application
You can also consult the meta-ktn layer for examples.