Jump to content

Qt for HarmonyOS/qt6 Host Build: Difference between revisions

From Qt Wiki
Created page with "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."
 
No edit summary
 
Line 1: Line 1:
To get Qt6 built on a HarmonyOS device, e.g. a 2-in-1 laptop, the instructions from [[Qt_for_HarmonyOS/qt5_Host_Build|Host Build for Qt5]] can be followed.
To get Qt6 built on a HarmonyOS device, e.g. a 2-in-1 laptop, the instructions from [[Qt_for_HarmonyOS/qt5_Host_Build|Host Build for Qt5]] can be followed.
This page contains additional information related to Qt6.
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 ====
* <code>TMPDIR</code> is <code>$HOME</code> (not usable). Set <code>TMPDIR=/tmp</code>.
* toybox <code>mktemp -d</code> makes <code>0700</code> dirs under <code>/storage/Users</code> that the real uid cannot write to, and <code>chmod</code> has no effect there. <code>mkdir</code> makes usable dirs. toybox <code>sh</code> has <code>mktemp</code> built in, so a PATH wrapper alone is not enough: autoconf <code>configure</code> must run under bash (<code>CONFIG_SHELL</code>), which then finds the wrapper <code>bin/mktemp</code>.
* <code>flock</code> only works under <code>/storage/Users</code>, not in <code>/tmp</code>, so vcpkg's buildtrees cannot live in <code>/tmp</code>.
* Executing a binary whose ELF was rewritten by <code>patchelf</code> fails with EPERM (signature invalidated). vcpkg runs <code>patchelf</code> on Linux-triplet packages, so it is switched off for the host triplet.
* <code>config.guess</code> does not know <code>uname -s</code> = <code>HarmonyOS</code>; 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 <nowiki>https://git.qt.io/qtbuildsystem/vcpkg</nowiki>
==== 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 <code>vcpkg version</code> find <code>libcurl.so.4</code>.
* Do not set <code>LD_LIBRARY_PATH=~/.harmonybrew/lib</code>: Harmonybrew's <code>libxml2</code> shadows the system one and the SDK's <code>lld</code> fails with <code>xmlFree: symbol not found</code>.
* With metrics enabled <code>vcpkg install</code> ends with "unable to find a libcurl.so.4" even with the rpath (cause not understood). Use <code>VCPKG_DISABLE_METRICS=1</code>.
* Every bootstrap run wipes <code>buildtrees/_vcpkg</code> and rebuilds, so keep <code>LDFLAGS</code> set 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.

Latest revision as of 09:40, 23 November 2026

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

  • TMPDIR is $HOME (not usable). Set TMPDIR=/tmp.
  • toybox mktemp -d makes 0700 dirs under /storage/Users that the real uid cannot write to, and chmod has no effect there. mkdir makes usable dirs. toybox sh has mktemp built in, so a PATH wrapper alone is not enough: autoconf configure must run under bash (CONFIG_SHELL), which then finds the wrapper bin/mktemp.
  • flock only works under /storage/Users, not in /tmp, so vcpkg's buildtrees cannot live in /tmp.
  • Executing a binary whose ELF was rewritten by patchelf fails with EPERM (signature invalidated). vcpkg runs patchelf on Linux-triplet packages, so it is switched off for the host triplet.
  • config.guess does not know uname -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 version find libcurl.so.4.
  • Do not set LD_LIBRARY_PATH=~/.harmonybrew/lib: Harmonybrew's libxml2 shadows the system one and the SDK's lld fails with xmlFree: symbol not found.
  • With metrics enabled vcpkg install ends with "unable to find a libcurl.so.4" even with the rpath (cause not understood). Use VCPKG_DISABLE_METRICS=1.
  • Every bootstrap run wipes buildtrees/_vcpkg and rebuilds, so keep LDFLAGS set 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.