Search by Tags

How to set up Qt Creator to cross compile for embedded Linux

Applicable for

Compare with Revision

Subscribe for this article updates

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 be built by OpenEmbedded for your host system. In this how to we use the distribution provided Qt Creator.

Build the SDK for Qt development

In order to compile the required libraries, a full OpenEmbedded build environment need to be in place at first (see OpenEmbedded (core)...).

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. There are two OpenEmbedded targets providing such a toolchain:

  • meta-toolchain-qt5: For Qt 5, create applications for X-Server or framebuffer with EGLFS without X-Server
  • meta-toolchain-qt: Qt 4.8 X11, create applications for X-Server
  • meta-toolchain-qte: Qt 4.8 Embedded, without X-Server directly on framebuffer (using QWT)

Qt Quick 2.0 which is part of Qt 5 uses a OpenGL based render. Since some of our modules to not support hardware accelerated OpenGL (e.g. NXP/Freescale Vybrid based Colibri VF50/VF61), be prepared for bad performance on those modules. Note: The Qt Company's commercial offerings (Qt for Device Creation) provide a optimized Qt Quick 2D Renderer specifically targeted for these modules.

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.

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.

In this example we use Qt 5:

$ bitbake -k meta-toolchain-qt5

This can take several hours.

Build and Deploy the Target Image for Qt

On the target module you will need the Qt runtime environment installed. Therefor a new image with the Qt run-time libraries to allow executing Qt applications on the target is required. This step is mandatory!

For Qt 5, build and setup with OpenEmbedded as per

As outlined in above mentioned OpenEmbedded article after changing your local.conf you may now build either of the following image targets for resp. feature set:

  • angstrom-lxde-image: for Qt 5 X11 included in our regular Angstrom LXDE desktop environment image
  • console-tdx-image: for Qt 5 with framebuffer EGLFS without X11 included in our regular console image
$ bitbake -k angstrom-lxde-image
$ bitbake -k console-tdx-image

Alternatively you may skip above local.conf modification and just build the following image target:

  • angstrom-qt5-x11-image: for Qt 5 X11 image without desktop
$ bitbake -k angstrom-qt5-x11-image

For Qt 4.8:

  • 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)
$ bitbake -k angstrom-qt-x11-image
$ bitbake -k qt4e-demo-image

Note: For more information concerning how to install your newly built image onto the target have a look at one of the following articles.

Note: Depending on the demo application Qt might use continuously CPU and/or GPU resources which can lead to a safety shutdown if operated without cooling solution.

Install the SDK

Install the Qt toolchain on your development computer (replace x86_64 with i686 if you use a 32-bit machine, also note the -S parameter which preserves the relocation scripts, we need them later on):

../deploy/sdk/ -S

For Qt 4.8, with a V2.4 image the above would be on the lines of

./out-glibc/deploy/sdk/ -S

The default destination folder is /usr/local/oecore-x86_64 or /usr/local/oecore-i686 (depending on architecture).

For Qt 5, starting qmake should succeed now:

$ /usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/qt5/qmake
Usage: /usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/qt5/qmake [mode] [options] [files]

Note: For Qt 4.8, in OpenEmbedded core versions used in BSP V2.4, the relocation of SDK excludes some files which results in segmentation faults (beside qmake2, also try to run the python binary):

$ /usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/qmake2
Segmentation fault (core dumped)

If this is the case for you, you can try the following work around: Alter the relocation script located at /usr/local/oecore-x86_64/ by removing line 95/96:

-            if fname.startswith("/lib/") or fname.startswith("/lib64/") or fname.startswith("/lib32/") or fname.startswith("/usr/lib32/") or fname.startswith("/usr/lib32/") or fname.startswith("/usr/lib64/"):  
-                break

And run the relocation again:

$ sudo /usr/local/oecore-x86_64/

Starting qmake2 should succeed now:

$ /usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/qmake2
Usage: /usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/qmake2 [mode] [options] [files]

Install Qt Creator

Current long-term release (Ubuntu 14.04) provide Qt Creator 3.0, which is sufficient recent for this how to.

If you would like to use newer Qt Creator versions one can add an additional repository located at (Qt Creator 3.1.1 at the time of writing).

$ sudo add-apt-repository ppa:ubuntu-sdk-team/ppa
$ sudo apt-get update
$ sudo apt-get install qtcreator qt4-dev-tools

Configure Qt Creator

Before starting Qt Creator, we have to export some build environment variables. Qt uses special configuration files to describe the build 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 which does all the hard work.
Source the script as follows:

. /usr/local/oecore-x86_64/environment-setup-armv7at2hf-neon-angstrom-linux-gnueabi

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:


Add the Target Device

Go to Tools => Options. In the left panel, click on Devices and add a new device representing the target Colibri Module:

  • Press Add and choose Generic Linux Device
    • Specifiy a name (e.g. Colibri VF61)
    • Fill in the device's IP address
    • Authentication on our modules by default: Password, User ''root'', empty password

Qt Creator - Devices

Add Kit

In the left panel, click on Build & Run and configure in the following tabs:

  • Qt Versions:
    • Press Add
    • Choose /usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/qmake2
    • Fill in a name

Qt Creator - Qt Versions

  • Compilers:
    • Press Add => Gcc
    • Name: GCC (Qt Embedded)
    • Compiler path: /usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/arm-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-g++
    • ABI (should be detected automatically): arm-linux-generic-elf-32bit

Qt Creator - Compilers

  • Debuggers:
    • Press Add
    • Name: GDB (Qt Embedded)
    • Path: /usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/arm-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-gdb

Qt Creator - Debuggers

  • Kit
    • Press Add
    • Name: Toradex Qt Embedded
    • Device: Colibri VF61
    • Sysroot: /usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-neon-angstrom-linux-gnueabi
    • Compiler: GCC (Qt Embedded)
    • Debugger: GDB (Qt Embedded)
    • Qt version: Qt 4.8.6 (Toradex BSP Qt Embedded)
    • Qt mkspec: leave empty

Qt Creator - Kits

Now one can create a new project using the new Kit. Qt Creator automatically configures build configurations for the cross compiling Kit.

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: With Qt 5.7 from OpenEmbedded Morty release (BSP version 2.7 Beta1 and later) require Qt mkspec to be set as follows


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 using the Qt for Embedded Linux server).

See also