Last edited 4 days ago

How To build Qt applications using STM32CubeIDE

Applicable for STM32MP13x lines, STM32MP15x lines, STM32MP23x lines, STM32MP25x lines

Warning DB.png Important
This version of X-LINUX-QT expansion package is validated against the ecosystem release v6.0.0 More info.png . Porting on ecosystem release v6.1.0 More info.png is ongoing. Target Q3 26

This article explains how to use the X-LINUX-QT developer package to build Qt applications for the STM32 microprocessor series with STM32CubeIDE. It has been written for STM32MP2 series but it can be adapted easily to STM32MP1 series.

1. Prerequisites[edit | edit source]

Check first detailed prerequisites in X-LINUX-QT_Expansion_Package#Prerequisites and X-LINUX-QT Developer Package#Prerequisites.

Then X-LINUX-QT developer package is up and running on your board. For that, follow information provided in X-LINUX-QT Developer Package article.

2. Update the SDK environment for CMake[edit | edit source]

Info white.png Information
The OE_CMAKE_TOOLCHAIN_FILE variable needs to be set to allow building CMake projects with the installed SDK

Follow the steps below if it is necessary to add the missing OE_CMAKE_TOOLCHAIN_FILE variable to the SDK configuration.

  • Open the terminal and load the environment setup:
 source /opt/st/stm32mp2/5.0.3-openstlinux-6.6-yocto-scarthgap-mpu-v24.11.06/environment-setup-cortexa35-ostl-linux
  • Add the missing OE_CMAKE_TOOLCHAIN_FILE variable to the qt6 environment file:
 echo "export OE_CMAKE_TOOLCHAIN_FILE=\"\$OECORE_NATIVE_SYSROOT/usr/lib/cmake/Qt6/qt.toolchain.cmake\"" >> $OECORE_NATIVE_SYSROOT/environment-setup.d/qt6.sh

3. Install the STM32CubeIDE[edit | edit source]

  • Follow the instructions from STM32CubeIDE article to know how to install and use the STM32CubeIDE.

4. Select the OpenSTLinux SDK updated by the X-LINUX-QT developer package[edit | edit source]

  • Follow the instructions from How_to_install_the_Yocto_Project_SDK_in_STM32CubeIDE article to know how to install the STM32MPU OpenSTLinux developer package for the STM32CubeIDE.
  • Select the STM32MPU OpenSTLinux developer package previously updated by the X-LINUX-QT developer package.

5. Download the demo example source code[edit | edit source]

 mkdir -p /opt/st/demos/Qt
 cd /opt/st/demos/Qt
 git clone https://github.com/KDABLabs/KDBoatDemo.git -b qt6

6. Build the demo example[edit | edit source]

6.1. Import the project from STM32CubeIDE[edit | edit source]

  • Start a new STM32 CMake project:
STM32CubeIDE New CMake Project 01.png


  • Select Project with existing CMake sources
STM32CubeIDE New CMake Project 02.png


  • Fill the Project name and source directory.
    • Project name = KDBoatDemo
    • Source directory = /opt/st/demos/Qt/KDBoatDemo
STM32CubeIDE New CMake Project 03.png


  • Configure the default toolchain.
    • Select OpenSTLinux SDK for the Toolchain field.
    • Select the installed OpenSTLinux SDK for the Version field.
Picture is not contractual (based on previous OpenSTLinux version)


6.2. Build the project[edit | edit source]

  • Select the project from the list and press the Build button:
STM32CubeIDE Build CMake Project 01.png
  • Wait until the build is finished and make sure it is done successfully:
Picture is not contractual (based on previous STM32CubeIDE version

7. Deploy the demo example to your running board[edit | edit source]

  • Copy the example's binary into your connected board:
 cd /opt/st/demos/Qt
 scp config_default/KDABBoatDemo root@<board_ip>:/home/root/.

8. Run the demo example on the board[edit | edit source]

  • Connect to the running board:
 ssh root@<board_ip>
  • Run the demo's example (windowed mode):
 ./KDABBoatDemo
  • Check the running demo example on the board's display:
Running KDAB Boat demo on target (Windowed Mode)
  • Run the demo's example (Full screen mode):
 ./KDABBoatDemo --fullscreen
  • Check the running demo example on the board's display:
Running KDAB Boat demo on target (Full screen Mode)