HMI
Configuring Qt-Creator on Ubuntu 20 LTS for cross-compilation

Introduction

This is a guide for configuring Qt Creator in order to be able to use cross-compiled Qt libraries for the Raspberry Pi 4 and create applications for the Raspberry.

Requirements

Raspberry Pi OS Lite

Install Raspberry Pi OS Lite on a Raspberry Pi 4 or on a Raspberry Compute Module 4 – as described in my blog post Installing Raspberry Pi OS on the Raspberry Compute Module 4.

Qt 5.15.2 on Ubuntu 20 LTS

Configure Raspberry Pi OS Lite on a Raspberry Pi 4 or on a Raspberry Compute Module 4 – as described in my blog postInstalling Raspberry Pi OS on the Raspberry Compute Module 4 and create the Qt libraries as described in my blog post Qt 5.15 cross-compilation for Raspberry Compute Module 4 on Ubuntu 20 LTS.

Qt Creator configuration

You should have a working Qt Creator installed on an Ubuntu 20. Instructions for doing this can be found at Qt or in various forums or tutorials. In addition – as described in the requirements – you should have set up a Raspberry Pi 4 or a Raspberry Compute Module 4 with Raspberry Pi OS Lite and the corresponding Qt libraries, a cross-compiler, and the cross-compiled libraries for the Raspberry Pi 4.
The paths then used for the various configurations correspond to the paths from the two previous blog posts. The version of QtCreator I have used is Version 4.13.3.

Setting up the device

As the first step, we need to create a new device. To do this, call up "Options" in the menu under "Tools" and select "Devices" in the left column. Then use "Add" to create a new "Generic Linux Device". Assign a name to the device – here I have used RaspberryPi4-Qt- 5.15. Enter the IP address under "Host name", and, under "Username", enter "pi", typically, for the Raspberry. Then you can test the connection to the Raspberry using the "Test" button. If "Device test finished successfully." is not returned, you will have to check the settings and test whether the Raspberry can really be reached with these parameters.

QtCreator Device Configuration

Configuring the compilers

For the second step, we have to define the paths for the C and C++ compilers. The settings for this can again be found in the "Tools -> Options" menu under "Kits -> Compilers". Here, we are using the compilers that we downloaded with the cross compiler "gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf". Add two new configurations using "Add -> GCC -> C" or "Add -> GCC -> C++". To do this, in the "Tools" directory, use "gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc" for C and "gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++" for C++. Assign a name for each, and then this setup will be complete.

QtCreator Compiler Configuration

Creating the Qt version

For the third step, we need the cross-compiled qmake file from the previous blog post. The settings for this can be found in the menu "Tools -> Options" under "Kits -> Qt Versions".
Use "Add" again to add a new configuration and use the "Browse" button to select the qmake file from the directory "qt5.15/bin/qmake".

QtCreator Version Configuration

Creating the kit

For the last step, we combine the newly added configurations to form a new kit. The settings for this can be found in the "Tools -> Options" menu under "Kits -> Kits".
Use "Add" again to add a new configuration and do the following:

  • Name: assign your own name (this will be used later to select the device under the "Project" settings)
  • Device type: "Generic Linux Device"
  • Device: select the newly created device
  • Sysroot: select the sysroot directory created in the previous blog post
  • Compiler: select the two newly created compilers
  • Qt-Version: select the newly created Qt Version
QtCreator Kit Configuration

Project settings

The newly created kit can now be selected and assigned immediately when creating a new project or be added to an existing project.

QtCreator Project Configuration