OpenHarmony
Prerequisites
- First, add the ohos target platform. If you haven't installed
cargoyet, click here to install the build tools for your system.
For more information, refer to ohos-rs.
rustup target add aarch64-unknown-linux-ohos
rustup target add armv7-unknown-linux-ohos # theoretically optional
rustup target add x86_64-unknown-linux-ohos # theoretically optional, unless running on x86 emulator- Download the latest
DevEco-Studioand install the correspondingNDK. You can find it at DevEco Studio (Windows/macOS) or configure Command Line Tools (recommended for Linux).
After downloading, set an environment variable to help build the native module. Assuming your SDK is installed at /path/Sdk:
| Platform | NDK Path | How to Set |
|---|---|---|
| macOS | /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony | Run in terminal:export OHOS_NDK_HOME=/Applications/DevEco-Studio.app/Contents/sdk/default/openharmonyAdd to ~/.zshrc or ~/.bash_profile to make it permanent |
| Windows | C:/Program Files/Huawei/DevEco Studio/sdk/default/openharmony | 1. Open System Environment Variables 2. Create a new system variable OHOS_NDK_HOME3. Set the value to the path above Or set temporarily in PowerShell: $env:OHOS_NDK_HOME="C:/Program Files/Huawei/DevEco Studio/sdk/default/openharmony" |
| Linux | Custom path after installing Command Line Tools | Run in terminal:export OHOS_NDK_HOME=/your/download/path/openharmonyAdd to ~/.bashrc or ~/.profile to make it permanent |
Note:
DevEco StudioorCommand Line Toolsversion must be at least 6.0.0 (API 20). Only ARM macOS is recommended for development.
- Install ohrs:
cargo install ohrsBuilding
- First, clone the repositories.
git clone https://github.com/TeamFlos/phira
git clone https://github.com/TeamFlos/phira-ohosFor the static library, download
aarch64-unknown-linux-ohos.tar.gzfrom prpr-avc-ffmpeg and extract all*.afiles tophira/prpr-avc/static-lib/aarch64-unknown-linux-ohos.Add
config.tomlto configure the cmake location, required for compiling phira for the ohos platform.
$ cd phiraFor Linux:
.cargo/config.toml
[env]
CMAKE = "/your/ohos/sdk/command-line-tools/sdk/default/openharmony/native/build-tools/cmake/bin/cmake"
CMAKE_TOOLCHAIN_FILE_aarch64-unknown-linux-ohos = "/your/ohos/sdk/command-line-tools/sdk/default/openharmony/native/build/cmake/ohos.toolchain.cmake"
CMAKE_GENERATOR = "Ninja"
CMAKE_MAKE_PROGRAM = "/your/ohos/sdk/command-line-tools/sdk/default/openharmony/native/build-tools/cmake/bin/ninja"
OHOS_NDK_HOME = "/your/ohos/sdk/command-line-tools/sdk/default/openharmony"For Windows, create cmake-wrapper.cmd in the project's .cargo folder. We use temporary variables to avoid conflicts with the system's default cmake:
.cargo/cmake-wrapper.cmd
@echo off
set PATH=D:/your/ohos/sdk/default/openharmony/native/build-tools/cmake/bin;%PATH%
"D:/your/ohos/sdk/default/openharmony/native/build-tools/cmake/bin/cmake.exe" %*.cargo/config.toml
[env]
CMAKE = "your/project/path/.cargo/cmake-wrapper.cmd"
CMAKE_TOOLCHAIN_FILE_aarch64-unknown-linux-ohos = "D:/your/ohos/sdk/default/openharmony/native/build/cmake/ohos.toolchain.cmake"
CMAKE_GENERATOR = "Ninja"
CMAKE_MAKE_PROGRAM = "D:/your/ohos/sdk/default/openharmony/native/build-tools/cmake/bin/ninja.exe"- Start building:
phira> cd phira # Must enter the phira subfolder, otherwise no output will be generated
phira/phira> ohrs build --release --arch aarch # --arch can be omitted to build for x86_64, armv7, and arm64; current HarmonyOS devices are all arm64After a successful build, find
libphira.soinphira/dist/<arch>.The
phira-ohosrepository does not include resource files. Copy theassets/folder toentry/src/main/resources/resfile/assetsbeforehand. If the main program shows a black screen, go to the Release page, download any version, and copy the missing resource files to the same directory.Enter the
phira-ohosfolder, renamebuild-profile-nosigncfg.json5tobuild-profile.json5, then openDevEco Studio.
Connect your device, go to Project Structure, find Signing configs, select Automatically generate signature, and click Apply. The project will automatically trigger a Sync.

The location of Project Structure is shown by the arrow.
Copy the generated libphira.so to the entry/libs/arm64-v8a folder. Click Build to run on an ohos device.
Troubleshooting
If you encounter very strange build errors, consider switching to ARM macOS or WSL for compilation.
DevEco Studio does not have a native Linux version.