Qt for HarmonyOS - Building from Source

Note: Qt for HarmonyOS is in technology preview and may change in future releases.

This page describes how to configure and build Qt for HarmonyOS from source.

Prerequisites

Before continuing, make sure you meet all requirements from Qt for HarmonyOS Prerequisites.

Building Qt for HarmonyOS is a cross-compilation: you build the Qt libraries for the HarmonyOS target using build tools from a matching host Qt build. You therefore need a Qt build for your host platform first. For general background on cross-compiling Qt, see Qt for Device Creation and Cross-compiling Qt.

Configuring and building

Configure Qt for HarmonyOS by pointing the build at the OpenHarmony SDK and the host Qt build:

 configure -ohos-sdk <SDK_ROOT> -qt-host-path <HOST_QT_PATH> -ohos-arch arm64-v8a
 cmake --build .

The relevant configure options are:

  • -ohos-sdk sets the OpenHarmony SDK root path. If omitted, configure uses the value of the OHOS_SDK_ROOT environment variable.
  • -ohos-arch sets the target architecture. Use arm64-v8a for physical devices and x86_64 for the emulator. If omitted, configure selects an architecture based on the SDK.
  • -qt-host-path specifies the path to the Qt host build used for cross-compiling.

Installing

After the build finishes, install Qt for HarmonyOS:

 cmake --install .

By default, Qt is installed into /usr/local/Qt-<version>. Pass the -prefix option to configure to install into a different location. The resulting Qt for HarmonyOS installation is what you use to build and deploy applications, as described in Building and Deploying Qt Applications for HarmonyOS.