We're currently working on porting Qt to HarmonyOS. For our CI and developer machines, we need a number of third-party libraries built for HarmonyOS. Cross-compiling open-source C and C++ libraries for this platform has been a manual, error-prone process. Each library has its own build system, whether CMake, Autotools, or Meson. Each needs individual attention to produce correct binaries for the OHOS target. We have been maintaining a hand-written shell script that builds libraries one by one, with per-library workarounds for cross-compilation quirks. With our vcpkg fork, that script is now a single command. vcpkg is Microsoft's open-source C/C++ package manager. It already handles cross-compilation for Android, iOS, and other embedded targets. Adding HarmonyOS as a first-class platform means the entire vcpkg port catalog becomes available to OHOS developers without per-library build system surgery. Qt supports building against third-party libraries provided by vcpkg since some versions, and Qt 6.11 introduces a configure option to run vcpkg in manifest mode and automatically install dependencies. Unfortunately, vcpkg did not support HarmonyOS, but we addressed this shortcoming in our fork. The changes are small and focused. The vcpkg-tool fork (one commit) adds An OHOS toolchain file that delegates to the HarmonyOS SDK's native toolchain Three community triplets: arm64-ohos, arm-ohos, x64-ohos Platform detection so that port expressions like Portfile patches for libraries that need OHOS-specific adjustments (for now: libpng, fontconfig, ICU) HarmonyOS SDK with native toolchain (API 12+) CMake 3.20+, Ninja Git The upstream vcpkg-tool does not yet recognize OHOS, so we build from our fork: Depending on where you've installed the HarmonyOS command line tools: The directory should contain To install the libraries into a common install root, we use vcpkg's "classic mode" (as opposed to "manifest mode"): That is it. vcpkg resolves dependencies, downloads sources, cross-compiles everything with the OHOS toolchain, and installs headers, libraries, and CMake config files into Or use vcpkg's own CMake integration: To instruct Qt to use vcpkg, pass The following triplets are available for HarmonyOS: All triplets produce dynamically linked libraries with unversioned sonames. We are working to upstream these changes to the official vcpkg and vcpkg-tool repositories. The goal is to provide standard community triplets, making OHOS a first-class vcpkg target alongside Android, iOS, and the other cross-compilation platforms. Once upstreamed, no forks will be needed. A standard vcpkg installation will support OHOS out of the box. Adding HarmonyOS support to vcpkg eliminates the per-library cross-compilation burden that every OHOS C/C++ developer faces today. Instead of maintaining custom build scripts for each dependency, the build recipes live in a community-maintained repository. If you are building native libraries for HarmonyOS, give our vcpkg fork a try and let us know how it works for you.Why vcpkg?
What our fork adds
ohos as a recognized platform identifier. Note that for historical reasons we use OHOS as a synonym for HarmonyOS. The SDK's toolchain file does the same. The vcpkg registry fork adds:
"supports": "!uwp" can include or exclude OHOSGetting started
Prerequisites
Step 1: Build vcpkg-tool from source
git clone https://git.qt.io/jobor/vcpkg-tool.git -b ohos ~/vcpkg-toolcd ~/vcpkg-toolcmake -S . -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFFninja buildStep 2: Set up the vcpkg registry
git clone https://git.qt.io/jobor/vcpkg.git -b ohos ~/vcpkgcd ~/vcpkgcp ~/vcpkg-tool/build/vcpkg ./export VCPKG_ROOT=~/vcpkgStep 3: Set the SDK path
export OHOS_SDK_ROOT=~/.local/opt/ohos/command-line-tools/sdk/default/openharmonynative/build/cmake/ohos.toolchain.cmake.Step 4: Install libraries
vcpkg install --triplet arm64-ohos libpng libjpeg-turbo ...$VCPKG_ROOT/installed/arm64-ohos.Step 5: Use in your project
cmake -S . -B build \ -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake \ -DVCPKG_TARGET_TRIPLET=arm64-ohosQT_USE_VCPKG=ON to configure. Qt's build system will automatically figure out where the vcpkg toolchain file is and use it.Available triplets
Triplet
OHOS ABI
arm64-ohos
arm64-v8a
arm-ohos
armeabi-v7a
x64-ohos
x86_64
Upstreaming
Conclusion