Qt for OpenHarmony: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
(52 intermediate revisions by 4 users not shown)
Line 1: Line 1:
=OpenHarmony Introduction=
=OpenHarmony Introduction=
OpenHarmony is an open-source project incubated and operated by the OpenAtom Foundation, with the goal of building a framework and platform for intelligent terminal device operating systems. It aims to cater to the era of full-scenario, full-connectivity, and full-intelligence, and promote the prosperous development of the Internet of Everything industry.
OpenHarmony is an open-source project incubated and operated by the OpenAtom Foundation, with the goal of building a framework and platform for intelligent terminal device operating systems. It aims to cater to the era of full-scenario, full-connectivity, and full-intelligence, and promote the prosperous development of the Internet of Everything industry.


[https://gitee.com/openharmony OpenHarmony Open source project]
[https://gitee.com/openharmony OpenHarmony Open source project]
=HUAWEI DevEco Studio Installation=
If you want to develop Qt for OpenHarmony applications, apart from using Qt Creator, you also need to rely on DevEco Studio.
https://developer.huawei.com/consumer/cn/deveco-studio/
For OpenHarmony 5, you need to install API Version 12:
[[File:DevEco_Studio_Preferences.png|alt=DevEco_Studio_Preferences|864x864px]]
To avoid any issues caused by the development environment, please first confirm if you can use DevEco Studio to develop Arkts applications.
=Gerrit Introduction=
The Qt source code is hosted on Gerrit for code review and version control. All needed information about how to work with Gerrit is written on the following pages:
*[[Setting up Gerrit]]
*[[Gerrit Introduction]]
=How to get Qt for OpenHarmony source code=
# Access and login to: https://codereview.qt-project.org.
# Click on the "Settings" in the upper right corner to open the settings page.
# Click on "Settings" -> "HTTP Credentials" -> "GENERATE NEW PASSWORD" to generate a new password. Save the password for later use with "git clone".
# Access https://codereview.qt-project.org/admin/repos/qt/tqtc-qt5, and copy the git repository address.
[[File:Codereview-settings.png|left|873x873px]]
[[File:GENERATE-NEW-PASSWORD.png|left|874x874px]]
[[File:Git-address.png|874x874px]]
=Building Qt Library for Qt for OpenHarmony in macOS=
=== Prepare for third-party dependencies ===
Following instruction has been prepared based on macOS Sonoma 14.0.  Does not represent a minimum dependency condition.
* git version 2.39.3
* python 3.12.0
=== System environments ===
Open ''~/.zshrc'' or ''~/.bashrc'' and add the following:<syntaxhighlight lang="shell">
local HARMONY_OS_API_VER=12
local HOME_LIBRARY=${HOME}/Library
export OHOS_SDK_ROOT=${HOME_LIBRARY}/OpenHarmony/Sdk
export HOS_SDK_HOME=${HOME_LIBRARY}/OpenHarmony/Sdk
export OHOS_SDK_12=${HOS_SDK_HOME}/${HARMONY_OS_API_VER}
export NATIVE_OHOS_SDK=${OHOS_SDK_12}/native
</syntaxhighlight>
=== Building Qt sources ===
You can use below script to build Qt for arm64-v8a target.
Please fill-in path to your local source directory.<syntaxhighlight lang="shell">
#!/bin/sh
# Target architecure
ARCH="arm64-v8a"
# Source and build directories
QT5_ROOT_DIR=<ENTER PATH TO YOUR qt/qt5 DIRECORY>
QT5_BUILD_DIR="$QT5_ROOT_DIR/build_${ARCH}"
# Prepare build directory
mkdir "$QT5_BUILD_DIR"
cd "$QT5_BUILD_DIR"
# Hack lack of ES2
python3 "$QT5_ROOT_DIR/hack_the_es2_lack.py" ${NATIVE_OHOS_SDK}/sysroot
../configure \
    -v \
    -xplatform ohos-clang \
    -prefix ${NATIVE_OHOS_SDK}/opt/Qt/5.12.12/ohos-${ARCH}-clang/ \
    -opensource \
    -confirm-license \
    -release \
    -no-use-gold-linker \
    -no-gcc-sysroot \
    -ohos-arch ${ARCH} \
    -opengles3 \
    -skip qt3d -skip qtactiveqt -skip qtandroidextras -skip qtcanvas3d -skip qtcharts \
    -skip qtconnectivity -skip qtdatavis3d -skip qtdoc -skip qtdocgallery -skip qtfeedback \
    -skip qtgamepad -skip qtgraphicaleffects -skip qtlocation -skip qtmacextras -skip qtnetworkauth \
    -skip qtpim -skip qtpurchasing -skip qtqa -skip qtremoteobjects -skip qtrepotools \
    -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport \
    -skip qtspeech -skip qtsystems -skip qttools -skip qttranslations -skip qtvirtualkeyboard \
    -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebglplugin -skip qtwebsockets \
    -skip qtwebview -skip qtwinextras -skip qtx11extras -skip qtxmlpatterns -skip doc \
    -no-dbus \
    -c++std c++14 \
    -make tests
</syntaxhighlight>then,<syntaxhighlight lang="shell">
make -j16
make install
</syntaxhighlight>
=Building Qt Application for OpenHarmony in macOS=
=== Preparing Qt Creator as a Qt IDE ===
==== Creating development kit for OpenHarmony in Qt Creator ====
Go to '''Preferences''' → '''Kits''' → '''Qt Versions'''.
Click the button '''Add…'''.
[[File:Macos-qtversion-add.jpg|left|869x869px]]
==== Configuring Qt Version ====
Select the '''qmake''' file generated by compiling the Qt for OpenHarmony source code:[[File:Macos-oh-qmake.jpg|left|867x867px]]
==== Configuring Compilers ====
Go to the Compilers tab. Click on the button Add, then select '''Custom''' → '''C'''.
[[File:Oh-compile-c.png|left|866x866px|Oh-compile-c]]
Set:
Name: '''OHOS Clang'''
Compiler path: '''/''path''/''to''/OpenHarmony/Sdk/12/native/llvm/bin/clang'''
Make Path: '''/usr/bin/make'''
ABI: '''arm - linux - generic - elf - 64bit'''
[[File:Compilers-filled.jpg|left|866x866px]]
Follow the above steps for the C++ compiler. However, this time, make sure to set Name to OHOS Clang++ and in Compiler path select the
clang++ instead.
[[File:CppCompilers-filled.jpg|866x866px]]
==== Configuring Kits ====
Go to '''Kits''' tab.
Click the '''Add''' button.
[[File:Kits.jpg|869x869px]]

Latest revision as of 02:49, 27 June 2025

OpenHarmony Introduction

OpenHarmony is an open-source project incubated and operated by the OpenAtom Foundation, with the goal of building a framework and platform for intelligent terminal device operating systems. It aims to cater to the era of full-scenario, full-connectivity, and full-intelligence, and promote the prosperous development of the Internet of Everything industry.

OpenHarmony Open source project