Skip to main content
Version: BSP 6.x.y

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

Introduction

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 Licensing Information

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.

info

Install the Partner Demo Image - Qt for Device Creation (Boot to Qt) for selected target modules using the Toradex Easy Installer.

Qt Creator

Qt 5

Install Qt Creator

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:

$ ./qt-unified-linux-x64-3.0.5-online.run
info

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.

Toradex Computer on Module: Boot to Qt component selection (click to enlarge)

For further information about Qt for Device Creation, refer to Partner Demo Image - Qt for Device Creation.

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:

Qt For Device Creation

Build and Deploy the Target Image

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.

Build the SDK for development

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.

Configure Qt Creator

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:

Qt 4.8

info

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.

Install Qt Creator

Using Ubuntu

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

Using Fedora

$ sudo dnf install qt4 qtcreator

Build and Deploy the Target Image

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

Build the SDK for development

info

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 SDK

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
Configure Qt Creator

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:

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

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.

qtcreator
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.

To make sure that the binaries get deployed to the root home folder, add the following to your .pro file:

*.pro
target.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.

info

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).

Other references


Send Feedback!