Qt for HarmonyOS/qt6 Host Build
To get Qt6 built on a HarmonyOS device, e.g. a 2-in-1 laptop, the instructions from Host Build for Qt5 can be followed. This page contains additional information related to Qt6.
Get vcpkg running
Steps to build vcpkg and OHOS libraries on the device itself, over SSH.
Device quirks that matter for builds
TMPDIRis$HOME(not usable). SetTMPDIR=/tmp.- toybox
mktemp -dmakes0700dirs under/storage/Usersthat the real uid cannot write to, andchmodhas no effect there.mkdirmakes usable dirs. toyboxshhasmktempbuilt in, so a PATH wrapper alone is not enough: autoconfconfiguremust run under bash (CONFIG_SHELL), which then finds the wrapperbin/mktemp. flockonly works under/storage/Users, not in/tmp, so vcpkg's buildtrees cannot live in/tmp.- Executing a binary whose ELF was rewritten by
patchelffails with EPERM (signature invalidated). vcpkg runspatchelfon Linux-triplet packages, so it is switched off for the host triplet. config.guessdoes not knowuname -s=HarmonyOS; the host triplet sets the build triplet explicitly.
Prerequisites
HarmonyBrew:
export PATH=$HOME/.harmonybrew/bin:$PATH brew install pkgconf patchelf autoconf automake libtool autoconf-archive make bash python ninja git curl ohos-sdk cmake
vcpkg checkout
cd ~/dev git clone https://git.qt.io/qtbuildsystem/vcpkg
bootstrap vcpkg-tool
export VCPKG_DISABLE_METRICS=1 cd ~/dev/vcpkg LDFLAGS="-Wl,-rpath,$HOME/.harmonybrew/lib" ./bootstrap-vcpkg.sh
- The bootstrap builds vcpkg-tool from source. The rpath lets
vcpkg versionfindlibcurl.so.4. - Do not set
LD_LIBRARY_PATH=~/.harmonybrew/lib: Harmonybrew'slibxml2shadows the system one and the SDK'slldfails withxmlFree: symbol not found. - With metrics enabled
vcpkg installends with "unable to find a libcurl.so.4" even with the rpath (cause not understood). UseVCPKG_DISABLE_METRICS=1. - Every bootstrap run wipes
buildtrees/_vcpkgand rebuilds, so keepLDFLAGSset each time.
Using vcpkg
Clone the Qt top-level repository and inspect vcpkg.json to determine which 3rdparty libs Qt uses for HarmonyOS.
Build those 3rdparty libs for the ohos-arm64 triplet. Alternatively, use Qt's overlay triplets to replicate what our CI does.