Building Qt6 for HarmonyOS
HarmonyOS SDK Version Requirements
The minimum supported HarmonyOS SDK API level is 23 from HarmonyOS 6.1.0 release.
HUAWEI DevEco Studio Installation
See also Building Qt for HarmonyOS#HUAWEI DevEco Studio Installation .
DevEco Studio is native IDE, it's available on Windows and macOS.
If only for build you can also try Command Line Tools, which is available on Windows, Linux and macOS.
Additional Packages
Qt 6 depends on lots of 3rdparty libraries, but HarmonyOS SDK doesn't provide them. So we have build one set for you - ohos-additional-packages-20260415.zip
Google Drive: https://drive.google.com/file/d/1muyUjBPS8B0CLEoLAhtGgxNY6C6W7TTl/view?usp=share_link
Baidu Netdisk: https://pan.baidu.com/s/1_x4mBtRuvwwO_oWjjH5CoQ?pwd=qtfh
sha1sum: fe3b77744659922977efd926b54a2534ff142f6a
This is only for development.
About how to build additional package, see https://www.qt.io/blog/building-libraries-for-harmonyos-with-vcpkg .
You can put it to ~/.local/opt/ohos/additional-packages .
How to get source code of qt5 and submodules
About gerrit and etc, details in Building Qt for HarmonyOS#Gerrit Introduction .
$ cd ~/qt
$ git clone git://code.qt.io/qt/qt5.git
$ cd qt5
# latest qt5 6.12, https://codereview.qt-project.org/c/qt/qt5/+/746950
$ git reset --hard c7581743be5270fbf4343508123a0897487cca87
# for example, we only want to try following submodules
$ git submodule update --init --recursive qtbase qtsvg qtimageformats qtshadertools qtlanguageserver qtdeclarativeHost Build
Use macOS(Apple Silicon) as example for now.
$ cd ~/qt
$ mkdir qt5-build
$ cd qt5-build
$ ../qt5/configure -release -developer-build -opensource -confirm-license -nomake examples -nomake tests -verbose -submodules qtbase,qtsvg,qtimageformats,qtshadertools,qtlanguageserver,qtdeclarative
$ cmake --build . --parallel -j14Target Build
With DevEco Studio installed, the sdk should be in /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/ .
(Note: if you are using other versions of DevEco Studio than 6.1.0 for API 23, you'd better to copy one sdk from it. For example, you can copy /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/ folder to ~/Library/OpenHarmony/Sdk/23 .)
$ cd ~/qt
$ mkdir qt5-harmonyos-build
$ cd qt5-harmonyos-build
$ ../qt5/configure -developer-build -nomake tests -debug -no-dbus -no-use-gold-linker -no-pch -openssl-runtime -ohos-sdk /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/ -qt-host-path ~/qt/qt5-build/qtbase -verbose -submodules qtbase,qtsvg,qtimageformats,qtshadertools,qtlanguageserver,qtdeclarative -- -DCMAKE_FIND_ROOT_PATH=~/.local/opt/ohos/additional-packages
$ cmake --build . --parallel -j14Build HarmonyOS Project for an example
$ cd ~/qt/qt5-harmonyos-build
$ mkdir qtbase-examples
$ cd qtbase-examples
$ ../qtbase/libexec/qt-internal-configure-examples ~/qt/qt5/qtbase
$ cmake --build . --parallel -j14 --target gallery
$ cd examples/widgets/gallery
$ ~/qt/qt5-build/qtbase/bin/harmonydeployqt --verbose --hvigor /Applications/DevEco-Studio.app/Contents/tools/hvigor/bin/hvigorw --input ./gallery-harmony-deployment-settings.json
$ cd libgallery-harmonyos
$ pwdUse DevEco Studio to open the above project, sign it and build it and run it.
Happy Hacking!