Skip to content

Qt X Compiling

vraevsky edited this page Aug 9, 2019 · 36 revisions

Intro

It is a quite common case when developing a QT based application for an Embedded Linux system is carried out on an host machine with a different architecture.

This is a brief manual that shows:

  • how to use the already compiled Yocto ARM64 SDK with Qt5 support;
  • how to configure and use it inside Qt Creator.

Including Qt X-compiling support in Yocto Project standard SDK

See: Prepare SDK Image

Sumo distribution for ARM 64-bit target

QtCreator Set Up

The following is an example on how to setup a Yocto Project standard SDK built using Sumo distribution for a Linux x86_64 host in Qt Creator 5.x:

  1. open the Tools, Options... menu and select the Kits section
  2. use <sdk-install-path>/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/qmake as qmake location in Qt versions tab:
  3. use <sdk-install-path>/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc as C compiler path and select ABI arm-linux-generic-elf-64bit in the Compilers tab:
  4. use <sdk-install-path>/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++ as C++ compiler path and select ABI arm-linux-generic-elf-64bit in the Compilers tab:
  5. use <sdk-install-path>/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gdb as debugger path in Debuggers tab:
  6. open the Devices section
  7. in the Devices tab create a new device of type Generic Linux Device, specify IP address and authentication details:
  8. return to the Kits section
  9. create a new kit with name X-compile ARM 64bit selecting the configurations we just created use <sdk-install-path>/sysroots/aarch64-poky-linux as sysroot path
  10. press Apply and exit Qt Creator

GUI Buid Method

  1. open a terminal application and source the cross compiling environment setup with:
    . <sdk-install-path>/environment-setup-aarch64-poky-linux

  2. start Qt Creator from the current command line:
    qtcreator

  3. create a new example project using the Qt Widgets Application template

  4. name the project hello-qt

  5. select the X-compile ARM 64bit kit we just created and finish

  6. edit the hello-qt.pro adding:

    # install
    target.path=/home/root/
    INSTALLS += target

  7. Build the project

  8. Run

  9. the hello-qt application should now start on the target embedded Linux device. Success!

Command Line Build Method

  1. open a terminal application and source the cross compiling environment setup with:
    . <sdk-install-path>/environment-setup-aarch64-poky-linux

  2. make the Qt5 SDK examples available for the developer:
    sudo chown ${USER}:${USER} -R <sdk-install-path>/sysroots/aarch64-poky-linux/usr/share/qt5/examples

  3. goto an opengl/hellogl2 directory:
    cd <sdk-install-path>/sysroots/aarch64-poky-linux/usr/share/qt5/examples/opengl/hellogl2

  4. issue this sequence:
    qmake -config release
    make -j 8

  5. issue file command and make sure that the produced binary is an ARM64 executable file:
    file hellogl2 | grep -q aarch64 && echo "good" || echo "bad"

  6. if it is a good, then copy this binary file to the target device and run it.