Jump to content

Building Qt6 for HarmonyOS: Difference between revisions

From Qt Wiki
Liang Qi (talk | contribs)
Liang Qi (talk | contribs)
 
(One intermediate revision by the same user not shown)
Line 38: Line 38:
$ git remote add gerrit https://codereview.qt-project.org/qt/qtbase
$ git remote add gerrit https://codereview.qt-project.org/qt/qtbase
$ git fetch gerrit
$ git fetch gerrit
# Current latest Patch Set 7 of the change
# Check out current latest Patch Set 13 of the change
$ git fetch https://codereview.qt-project.org/qt/qtbase refs/changes/51/733351/7 && git checkout FETCH_HEAD
$ git fetch https://codereview.qt-project.org/qt/qtbase refs/changes/51/733351/13 && git checkout FETCH_HEAD
 
</syntaxhighlight>
</syntaxhighlight>


Line 55: Line 56:
$ mkdir qtbase-harmonyos-build
$ mkdir qtbase-harmonyos-build
$ cd qtbase-harmonyos-build
$ cd qtbase-harmonyos-build
$ ../configure -developer-build -debug -no-dbus -no-use-gold-linker -no-pch -openssl-runtime -ohos-sdk /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/ -ohos-abis arm64-v8a -qt-host-path ~/qt/qtbase-host-build -- -DCMAKE_FIND_ROOT_PATH=~/.local/opt/ohos/additional-packages
$ ../qtbase/configure -developer-build -debug -no-dbus -no-use-gold-linker -no-pch -openssl-runtime -ohos-sdk /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/ -ohos-abis arm64-v8a -qt-host-path ~/qt/qtbase-host-build -- -DCMAKE_FIND_ROOT_PATH=~/.local/opt/ohos/additional-packages
$ cmake --build . --parallel -j14</syntaxhighlight>
$ cmake --build . --parallel -j14</syntaxhighlight>



Latest revision as of 11:28, 6 May 2026

See the latest change(s) to have HarmonyOS support in Qt 6(dev branch):

HarmonyOS SDK Version Requirements

The minimum supported HarmonyOS SDK API level is 20 from HarmonyOS 6.0.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.

Note: suggest to download 6.0.0(there is known issue with hvigor in DevEco Studio 6.0.2).

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 qtbase

About gerrit and etc, details in Building Qt for HarmonyOS#Gerrit Introduction .

$ cd ~/qt
$ git clone git://code.qt.io/qt/qtbase.git
$ cd qtbase
$ git remote add gerrit https://codereview.qt-project.org/qt/qtbase
$ git fetch gerrit
# Check out current latest Patch Set 13 of the change
$ git fetch https://codereview.qt-project.org/qt/qtbase refs/changes/51/733351/13 && git checkout FETCH_HEAD

Host Build

Use macOS(Apple Silicon) as example for now.

$ cd ~/qt
$ mkdir qtbase-host-build
$ cd qtbase-host-build
$ ../qtbase/configure -developer-build -opensource -confirm-license -no-framework -nomake examples -nomake tests -verbose
$ cmake --build . --parallel -j14

Target Build

With DevEco Studio installed, the sdk should be in /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/ .

$ cd ~/qt
$ mkdir qtbase-harmonyos-build
$ cd qtbase-harmonyos-build
$ ../qtbase/configure -developer-build -debug -no-dbus -no-use-gold-linker -no-pch -openssl-runtime -ohos-sdk /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/ -ohos-abis arm64-v8a -qt-host-path ~/qt/qtbase-host-build -- -DCMAKE_FIND_ROOT_PATH=~/.local/opt/ohos/additional-packages
$ cmake --build . --parallel -j14

Build HarmonyOS Project for an example

$ cd qtbase-harmonyos-build
$ cmake --build . --parallel -j14 --target gallery
$ cd examples/widgets/gallery
$ ~/qt/qtbase-host-build/bin/harmonydeployqt --verbose --hvigor /Applications/DevEco-Studio.app/Contents/tools/hvigor/bin/hvigorw --input ./gallery-harmony-deployment-settings.json
$ cd libgallery-harmonyos
$ pwd

Use DevEco Studio to open the above project, sign it and build it and run it.

Happy Hack!