Application Notes: Developing with Qt on CompuLab platforms
Revision as of 11:22, 18 August 2019 by imported>Igor.vaisbein (→Setup Qt Environment)
Contents
Introduction
Development of Qt based applications for Embedded Linux systems often needs to be done on a host machine with a different architecture. The following document outlines the configuration steps required in order to prepare the host machine for cross-compiling. This manual outlines two alternative methods of using Yocto SDK for Qt development:
Setting up Qt Development Environment
Setup Yocto SDK with Qt support
- Setup Yocto SDK with Qt support as detailed at Yocto SDK with Qt5 support.
The following manual assumes that the SDK install path is `/opt/fsl-imx-xwayland/4.14-sumo`. |
Setup Qt Environment
- Obtain a Linux Debian/Ubuntu desktop
- Install build-essential:
sudo apt-get install build-essential
- Install QtCreator:
sudo apt-get install qtcreator
- Make sure that Yocto SDK with Qt5 support is installed:
[[ -f /opt/fsl-imx-xwayland/4.14-sumo/environment-setup-aarch64-poky-linux ]] && echo "Installed" || echo "Not Installed"
- Make sure that the Qt5 support is enabled:
[[ -f /opt/fsl-imx-xwayland/4.14-sumo/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/qmake ]] && echo "enabled" || echo "off"
Using Yocto SDK without QtCreator
- Open a terminal window and source the cross compiling environment setup:
. /opt/fsl-imx-xwayland/4.14-sumo/environment-setup-aarch64-poky-linux
- Make the Qt5 SDK examples available for the developer:
sudo chown ${USER}:${GROUPS} -R /opt/fsl-imx-xwayland/4.14-sumo/sysroots/aarch64-poky-linux/usr/share/qt5/examples
- Go to opengl/hellogl2 project directory:
cd /opt/fsl-imx-xwayland/4.14-sumo/sysroots/aarch64-poky-linux/usr/share/qt5/examples/opengl/hellogl2
- Issue the following sequence:
qmake -config release make -j 8
- Issue `file` command and make sure that the produced binary is a valid ARM64 executable:
file hellogl2 | grep -q aarch64 && echo "good" || echo "bad"
- If the file is good, copy this binary file to the target device and run it.
- If the file is bad, re-issue the entire procedure .
Using Yocto SDK with QtCreator
Configuring QtCreator for use with Yocto SDK
The following example shows how to setup QtCreator with Yocto Project SDK built using Sumo distribution for a Linux x86_64 host:
- Open a terminal application and source the cross compiling environment setup with:
. /opt/fsl-imx-xwayland/4.14-sumo/environment-setup-aarch64-poky-linux
- Start QtCreator in the same terminal window:
qtcreator
- Open the Tools, Options... menu and select the Kits section
- Use the following line as qmake location in Qt versions tab:
/opt/fsl-imx-xwayland/4.14-sumo/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/qmake
- Use the following line as C++ compiler path and select ABI arm-linux-generic-elf-64bit in the Compilers tab:
/opt/fsl-imx-xwayland/4.14-sumo/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc
- Use the following line as C++ compiler path and select ABI arm-linux-generic-elf-64bit in the Compilers tab:
/opt/fsl-imx-xwayland/4.14-sumo/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++
- Use the following line as debugger path in Debuggers tab:
/opt/fsl-imx-xwayland/4.14-sumo/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gdb
- Open the Devices section
- Create a new device of type Generic Linux Device in the Devices tab , specify IP address and authentication details:
- Return to the Kits section
- Create a new kit with name X-compile ARM 64bit selecting the configurations we just created
Use the following line as sysroot path:
/opt/fsl-imx-xwayland/4.14-sumo/sysroots/aarch64-poky-linux
- Click Apply and exit Qt Creator
QtCreator configuration screenshots
Building a project using QtCreator
Make sure that the Configuring QtCreator for use with Yocto SDK was carried out first. |
- Open a terminal window and source the cross compiling environment setup:
. /opt/fsl-imx-xwayland/4.14-sumo/environment-setup-aarch64-poky-linux
- Start QtCreator in the same terminal window:
qtcreator
- Create a new example project using the Qt Widgets Application template
- Name the project hello-qt
- Select the X-compile ARM 64bit kit we just created and finish
- Edit the hello-qt.pro adding:
# install target.path=/home/root/ INSTALLS += target
- Build the project