Skip to content

Qt X Compiling

IgorVais edited this page Aug 12, 2019 · 36 revisions

Intro

It is a quite common case when developing Qt based applications for an Embedded Linux system is carried out on a host machine with a different architecture. In order to prepare the host machine for X-compiling some manual configuration steps required.

This is a brief manual that shows:

Assumptions

  • SDK install path is /opt/fsl-imx-xwayland/4.14-sumo

Requirements

  • Linux Debian/Ubuntu desktop
  • Install build-essential:
    sudo apt-get install build-essential
  • Install QtCreator:
    sudo apt-get install qtcreator
  • Yocto SDK with Qt5 support
    • Make sure that the SDK 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"

QtCreator Setup

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
  • in the same terminal window start QtCreator:

    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

  • in the Devices tab create a new device of type Generic Linux Device, 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

GUI Build Method

ℹ️ Make sure that the how to configure and use the SDK inside QtCreator ⤴️ was carried out first.

  • 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 from the current command line:
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
  • Run
  • the hello-qt application should now start on the target embedded Linux device. Success!

Command Line Build Method

  • open a terminal application and source the cross compiling environment setup with:
. /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
  • goto the opengl/hellogl2 project directory:
cd /opt/fsl-imx-xwayland/4.14-sumo/sysroots/aarch64-poky-linux/usr/share/qt5/examples/opengl/hellogl2
  • issue this sequence:
qmake -config release
make -j 8
  • issue file command and make sure that the produced binary is an ARM64 executable file:
file hellogl2 | grep -q aarch64 && echo "good" || echo "bad"
  • if it is a good, then copy this binary file to the target device and run it.
  • if it is a bad, then re-issue the entire procedure command line method.