Jump to content

Building Qt6 for HarmonyOS: Difference between revisions

From Qt Wiki
changed -ohos-abis to -ohos-arch
Liang Qi (talk | contribs)
mention how we keep multiple versions of sdk.
 
(2 intermediate revisions by the same user not shown)
Line 24: Line 24:
You can put it to ~/.local/opt/ohos/additional-packages .
You can put it to ~/.local/opt/ohos/additional-packages .


== How to get source code of qtbase ==
== How to get source code of qt5 and submodules ==
About gerrit and etc, details in [[Building Qt for HarmonyOS#Gerrit Introduction]] .
About gerrit and etc, details in [[Building Qt for HarmonyOS#Gerrit Introduction]] .
<syntaxhighlight lang="shell">
<syntaxhighlight lang="shell">
$ cd ~/qt
$ cd ~/qt
$ git clone git://code.qt.io/qt/qtbase.git
$ git clone git://code.qt.io/qt/qt5.git
$ cd qtbase
$ cd qt5
# add gerrit as remote
# latest qt5 6.12, https://codereview.qt-project.org/c/qt/qt5/+/746950
$ git remote add gerrit https://codereview.qt-project.org/qt/qtbase
$ git reset --hard c7581743be5270fbf4343508123a0897487cca87
$ git fetch gerrit
# for example, we only want to try following submodules
$ git checkout -b dev gerrit/dev
$ git submodule update --init --recursive qtbase qtsvg qtimageformats qtshadertools qtlanguageserver qtdeclarative
 
</syntaxhighlight>
</syntaxhighlight>


Line 40: Line 41:
<syntaxhighlight lang="shell">
<syntaxhighlight lang="shell">
$ cd ~/qt
$ cd ~/qt
$ mkdir qtbase-host-build
$ mkdir qt5-build
$ cd qtbase-host-build
$ cd qt5-build
$ ../qtbase/configure -developer-build -opensource -confirm-license -no-framework -nomake examples -nomake tests -verbose
$ ../qt5/configure -release -developer-build -opensource -confirm-license -nomake examples -nomake tests -verbose -submodules qtbase,qtsvg,qtimageformats,qtshadertools,qtlanguageserver,qtdeclarative
$ cmake --build . --parallel -j14
$ cmake --build . --parallel -j14
</syntaxhighlight>
</syntaxhighlight>


== Target Build ==
== Target Build ==
With DevEco Studio installed, the sdk should be in /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/ .<syntaxhighlight lang="shell">$ cd ~/qt
 
$ mkdir qtbase-harmonyos-build
With DevEco Studio installed, the sdk should be in /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/ .
$ 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-arch arm64-v8a -qt-host-path ~/qt/qtbase-host-build -- -DCMAKE_FIND_ROOT_PATH=~/.local/opt/ohos/additional-packages
(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 .)<syntaxhighlight lang="shell">$ 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 -j14</syntaxhighlight>
$ cmake --build . --parallel -j14</syntaxhighlight>


== Build HarmonyOS Project for an example ==
== Build HarmonyOS Project for an example ==
<syntaxhighlight lang="shell">
<syntaxhighlight lang="shell">
$ cd qtbase-harmonyos-build
$ 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
$ cmake --build . --parallel -j14 --target gallery
$ cd examples/widgets/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
$ ~/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
$ cd libgallery-harmonyos
$ pwd
$ pwd

Latest revision as of 13:57, 24 June 2026

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 qtdeclarative

Host 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 -j14

Target 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 -j14

Build 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
$ pwd

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

Happy Hacking!