This article describes how to build and configure a Qt Creator development environment on Linux to cross compile Qt applications for OpenEmbedded based root file systems. Qt Creator itself can be taken from your distributions repository, or its installer downloaded at Qt website under open-source or commercial licenses.
If you starting with Qt, this article may not provide the best user experience, though it is a comprehensive source of information. For a developer-friendly experience you can either follow:
Qt is a large framework with different licenses. Licenses also depend on which Qt version is used. Our partner, the Qt Company, can help you find the right license, therefore if you have questions consult the Qt Licensing page for details.
Note: Install the Partner Demo Image - Qt for Device Creation (Boot to Qt) for selected target modules using the Toradex Easy Installer.
Qt Creator provides a complete Integrated Development Environment for application developers to create applications for multiple targets such as embedded systems, mobile devices, desktops. One can install Qt Creator from its installer or from your distribution repository. Choose your option from the tabs below:
To install Qt Creator from its installer, download it according to the chosen license. Make sure that you always have the latest release installed.
Run the installer:
Note: It might be necessary to change the installer file mode to executable.
The commercial license enables Qt For Device Creation which provides a set of ready-to-use tools for developing in Qt Creator IDE for embedded systems such as Yocto based Boot to Qt pre-built images and cross-compilation toolchains for a series of target devices (Apalis iMX8 and iMX6, Colibri iMX6 and iMX7). These components must be installed during Qt Creator installation.
For further information about Qt for Device Creation, refer to Partner Demo Image - Qt for Device Creation.
Ubuntu 18.04 provides Qt Creator 4.5.2, which is sufficiently recent for this how-to.
Attention: it is preferred that you always use the latest Qt Creator version, available in the tab Qt Creator Installer. Customers using Ubuntu 16.04 LTS have reported issues due to the old version of Qt Creator available from the distribution repository.
sudo apt install build-essential sudo apt install qtcreator qt5-doc qt5-doc-html qtbase5-doc-html qtbase5-examples
Visit the Qt Creator Manual for further information about the IDE and its features according to the given license.
Once Qt Creator is installed in the host machine, it is necessary to have a Qt-enabled target device image as well as a built Software Development Kit (SDK). At last, this SDK must be configured in Qt Creator in order to build and deploy applications in your target module.
In order to have a Qt enabled target device image and SDK, it is possible to go with one of the following options:
Each one of the options has its steps described in the tabs below:
For Qt 5, one can install a Boot to Qt pre-compiled evaluation image directly from Toradex Easy Installer. With the commercial license of Qt For Device Creation, you will also get access to the QBSP - the SDK ready-to-use with Qt Creator.
In case Toradex Easy Installer is not available for your module, get your image into an SD card in a couple of clicks going to the Qt Creator top bar option Tools → Flash Boot to Qt device.
We need to have a full Qt toolchain, which provides besides cross GCC and GDB also the Qt headers to include and libraries to link against. With the commercial Qt For Device Creation, you can use the pre-compiled QBSP for evaluation.
Either if you are going to install the pre-compiled QBSP for evaluation, or if you already need to build your own custom QBSP with specific dependencies for your application, please refer to the Boot to Qt installation guides. The article Building Your Own Embedded Linux Image may be particularly useful, especially after the evaluation phase when you must build your own QBSP.
The QBSP makes it very easy to configure Qt Creator. Read the Qt for Device Creation Installation Guides. For setting-up the pre-compiled QBSP there are two options:
For BSP 5, our Reference Images for Yocto Project, more specifically the Multimedia Reference Image, comes with all the Qt5 packages included in packagegroup-tdx-qt5.bb. You can tweak this image to add or remove packages, including Qt5 packages.
For evaluation, you can install the pre-built image from our Toradex Easy Installer feeds. But do notice that we don't provide a pre-built QBSP/SDK for this image, you have to build it by yourself.
Refer to the article Build a Reference Image with Yocto Project to learn how to build and customize the Multimedia Reference Image, and generate an SDK for it.
For BSP 5, please use the Multimedia Reference Image as the base for customization, as explained the previous section.
You may find it useful to read the Toradex article Build a Reference Image with Yocto Project and The Qt Company article Building Your Own Embedded Linux Image.
It is recommended that you build a QBSP and and install it as described in the Qt For Device Creation section from this article. If you only build a regular SDK with OpenEmbedded/Yocto, then you may find some tips the legacy information below, though it is not guaranteed to work:
Warning: Boot to Qt for Embedded Linux is not maintained nor supported by Toradex. You can post your question in the Qt Forum, or contact The Qt Company support if using a commercial license.
For Qt 5, one can install a Boot to Qt evaluation image directly from Toradex Easy Installer. Read the article Partner Demo Image - Qt for Device Creation (Boot to Qt) to learn more.
To build a custom Boot to Qt image, it is necessary to setup an environment on your host PC to build images with the Yocto Project-based on Toradex BSP and Boot to Qt for embedded Linux.
Please refer to Build Your Own Embedded Linux Image article to solve the dependencies associated to the environment and complete this setup according to your host operating system.
Note: this section is limited up to the BSP 2.8. Qt 4 is not integrated with BSP 3 onwards, nor instructions on how to do it are provided.
Current long-term release (Ubuntu 18.04) provides Qt Creator 4.5.2, which is sufficient recent for this how-to.
$ sudo apt install qt4-default qtcreator
$ sudo dnf install qt4 qtcreator
On the target module, you will need the Qt runtime environment installed. Therefore a new image with the Qt run-time libraries to allow executing Qt applications on the target is required. This step is mandatory!
To build a Qt 4.8 enabled image, it is necessary to set up an environment on your host PC to build images with Yocto Project based on the OpenEmbedded layers and Toradex BSP. Please refer to the OpenEmbedded (core) article to solve the dependencies associated with the environment and complete this setup according to your host operating system.
There are two target images with Qt 4.8 packages available - angstrom-qt-x11-image : for Qt X11 image (recommended for Tegra and i.MX6 based modules) - qt4e-demo-image: for Qt Embedded image (recommended for VFxx)
To build them, run
[build] $ bitbake -k angstrom-qt-x11-image
[build] $ bitbake -k qt4e-demo-image
Note: See also Linux SDKs
In order to compile the required libraries, a full OpenEmbedded build environment need to be in place at first (see the Build and Deploy the Target Image for Qt).
We need to have a full Qt toolchain, which provides beside cross GCC and GDB also the Qt headers to include and libraries to link against.
The Qt 4.8 Embedded is still useful for devices without any graphical acceleration or with drivers providing this also to users relying on the frame buffer device. With the modules based on T20/T30 the drivers for hardware-accelerated 3D and video decoding are only available for an X11 system, so you probably want to use Qt on X11.
Install the Qt toolchain on your development computer (replace x86_64 with i686 if you use a 32-bit machine):
[build] $ cd ../deploy/sdk/ [sdk] $ ./deploy/sdk/angstrom-glibc-x86_64-armv7at2hf-vfp-neon-toolchain-qte-v2014.12.sh
Before starting Qt Creator, we have to export some build environment variables. Qt uses special configuration files to describe the built environment called mkspecs (they specify which compiler, linker, or other tools to use). However, this configuration files still need to know where the compiler (or cross-compiler in our case) is located. The SDK created a script that does all the hard work.
Using the SDK built with OpenEmbedded layers, source the script as follows:
Warning: It is required to source the script to export the environment variables every time in the same terminal session you run Qt Creator
The environment variable OE_QMAKE_CXX should then show something along this line:
$ echo $OE_QMAKE_CXX arm-angstrom-linux-gnueabi-g++ -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi
Now, start Qt Creator in the shell where you sourced the script.
Go to Tools → Options. In the left panel, click on Devices and add a new device representing the target Colibri Module:
In the left panel, click on Build & Run and configure in the following tabs:
Now one can create a new project using the new Kit. Qt Creator automatically configures build configurations for the cross-compiling Kit.
To make sure that the binaries get deployed to the root home folder, add the following to your
*.protarget.path = /home/root INSTALLS += target
If you have an existing project, you can configure Build & Run Configurations under the Project tab on the left side. Go to Add Kit, we can now use the newly created Kit Toradex Qt Embedded.
Note: When using Qt Embedded, you may want to switch to the "Run" configuration and add the argument "-qws" to the binary as standalone (instead of using the Qt for Embedded Linux server).