C

Set up your Development Host

Qt for MCUs supports Linux and Windows host environments. The following subsections provide the setup information for these host platforms.

Prerequisites

Intall the following prerequisites and also the Qt for MCUs in addition. You can install Qt for MCUs using the Qt online installer, which can be downloaded from your Qt account page.

Linux host

  • GNU Compiler Collection v7.4.0 or newer
  • GNU Make
  • X C Binding, xinerama extension library (libxcb-xinerama0)
  • CMake 3.17.3 or newer (you can install it using the Qt Online installer)

All these prerequisites can be installed using the following commands:

sudo apt update
sudo apt install build-essential libxcb-xinerama0 cmake

Windows host

  • MSVC++ compiler v14.16 (Visual Studio 2017 15.9) or newer
  • CMake 3.17.3 or newer (you can install it using the Qt Online installer)

Qt Creator setup

The following instructions help you set up Qt Creator on the Linux and Windows platforms.

To develop for MCUs using the Qt Creator IDE, the MCU plugin is required. The Qt online installer enables it by default when you install the Qt for MCUs SDK.

To enable or disable the plugin, follow these instructions:

  1. Select Help > About Plugins and choose the MCU Support plugin from the list.
  2. Restart Qt Creator to apply changes

To build and run your application on MCUs, you must create a kit:

  1. Select Tools > Options > Devices > MCU
  2. If not already set, provide the path to the Qt for MCUs installation directory.
  3. Select a Target supported by the Qt for MCUs SDK. For example, Qt for MCUs 1.9 - Desktop 32bpp.
  4. In the Requirements section, ensure that the platform-specific requirements are met.
  5. Select Automatically create kits for all available targets on start to create kits automatically.

    Note: You could also manually create/remove kits using Create Kit and Remove Kit.

  6. Click Apply and restart Qt Creator if you choose to create kits automatically.

Note: The Automatically create kits for all available targets on start option is available from Qt Creator v4.14 onwards. On older versions of Qt Creator, you have to explictly create or remove kits using Create kit or Remove kit.

Command line setup

Setting up the project

To configure a project, run CMake from the command prompt. Navigate to your project directory and enter the following commands, which uses the <INSTALL_ROOT>\demos\thermo demo as an example.

Important: This guide uses <INSTALL_ROOT> to refer to the Qt for MCUs install directory.

Linux host:

export Qul_DIR=<INSTALL_ROOT>
cd $Qul_DIR/demos/thermo
mkdir build_linuxqt
cd build_linuxqt
cmake .. -DQUL_PLATFORM=Qt

Windows host:

C:\Users\John> set Qul_DIR=<INSTALL_ROOT>
C:\Users\John> cd %Qul_DIR%\demos\thermo
<INSTALL_ROOT>\demos\thermo> mkdir build_winqt
<INSTALL_ROOT>\demos\thermo> cd build_winqt
<INSTALL_ROOT>\demos\thermo\build_winqt> cmake .. -DQUL_PLATFORM=Qt -Ax64

These commands check for the prerequisites and configure your project for Visual Studio.

Building

To build, use the following command:

cmake --build . --target thermo_big --config Release

Running the application

Once the thermostat application is built, try to running it:

Linux host

./thermo_big

Windows host

The thermo demo is built as a Qt application for Windows, so it requires the Qt runtime libraries in the PATH to run. Qt for MCUs provides all these necessary Qt libraries, which must be added to your PATH.

<INSTALL_ROOT>\demos\thermo\build_winqt> set PATH=%Qul_DIR%\bin;%PATH%

Now that your PATH includes the necessary libraries, run the application:

<INSTALL_ROOT>\demos\thermo\build_winqt>Release\thermo_big.exe

The Thermostat application window should look like this:

Visual Studio setup on Windows

Setting up the project

To configure the project, follow instructions in the Command line setup section.

Open the solution in Visual Studio

To work with your project using Microsoft Visual Studio, open the solution created by CMake from the build_winqt folder.

Now, you should see the solution tree structure.

As this is a Windows Qt project, it requires Qt's runtime libraries to run. To make them available for the built application, you must set the runtime environment. To do this:

  1. Right-click on your project and select Properties from the context menu.
  2. Click General > Debugging
  3. To Environment add the PATH variable pointing to the directory containing the Qt libraries. Those should be located inside the bin folder of your Qt for MCUs install root, for example:
    PATH=%Qul_DIR%\bin

After this step (assuming %Qul_DIR% was set to C:\QtForMCU\1.1.0) the project properties window should look like this:

Build & run

Apply the changes, build the application, and run it. You should see on the screen the thermostat demo.

Available under certain Qt licenses.
Find out more.