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.
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 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:
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.
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 http://developer.toradex.com/software-resources/arm-family/linux/board-support-package/openembedded-(core)#Adding_the_Qt5_Layer
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:
$ 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:
$ bitbake -k angstrom-qt5-x11-image
For Qt 4.8:
$ 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 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):
For Qt 4.8, with a V2.4 image the above would be on the lines of
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/relocate.py 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/relocate_sdk.sh
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] ...
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 https://launchpad.net/~ubuntu-sdk-team/+archive/ubuntu/ppa (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
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:
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.
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).