Skip to content

docs: add manual Android cross-compilation instructions - #210

Open
jaoleal wants to merge 1 commit into
sedited:masterfrom
jaoleal:manual-android-docs
Open

docs: add manual Android cross-compilation instructions#210
jaoleal wants to merge 1 commit into
sedited:masterfrom
jaoleal:manual-android-docs

Conversation

@jaoleal

@jaoleal jaoleal commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Add a standalone section documenting how to cross-compile for Android without Nix: NDK prerequisites, Rust target installation, environment setup (PATH, Boost discovery), cargo build commands for both the -sys and higher-level crate, linker binary names table, and API level override.

Depends on #158

@jaoleal

jaoleal commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Should i add a entry for this change on CHANGELOG ?

@alexanderwiederin alexanderwiederin added the no-changelog This PR does not require a CHANGELOG entry (e.g. docs, tests, CI changes). label Jul 23, 2026
@alexanderwiederin

Copy link
Copy Markdown
Collaborator

I think we should have the instructions with nix in README.md. For the manual cross-compilation I would add a new file (ANDROID.md) and link to it in the README.md

Should i add a entry for this change on CHANGELOG ?

Just added the no-changelog label.

@jaoleal
jaoleal force-pushed the manual-android-docs branch from 490e2c8 to b280ff1 Compare August 6, 2026 15:42
Nix remains the recommended path for Android cross-compilation and stays
documented in the README. Add ANDROID.md for building without Nix: NDK
prerequisites, Rust target installation, environment setup (PATH, Boost
discovery), cargo build commands for both the -sys and higher-level
crate, linker binary names table, and API level override. Link to it
from the README's Android section.
@jaoleal
jaoleal force-pushed the manual-android-docs branch from b280ff1 to 02544d4 Compare August 6, 2026 15:46
@jaoleal
jaoleal marked this pull request as ready for review August 6, 2026 15:47
@jaoleal

jaoleal commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Done @alexanderwiederin

Github is trolling

@jaoleal

jaoleal commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Can we have a release after this one ?

@sedited

sedited commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Can we have a release after this one ?

Yes, I'll defer back to Alex here though, and we should wait for the CI to come back again in any case.

@alexanderwiederin alexanderwiederin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I would suggest we add a ci job like this one.

Also suggested something in the environment/boost section - question is inline.

Comment thread ANDROID.md

## Prerequisites

Android NDK (r27+ recommended), cmake, and Boost headers installed on the

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Android NDK (r27+ recommended), cmake, and Boost headers installed on the
Android NDK (tested with r27.3), cmake, and Boost headers installed on the

Comment thread ANDROID.md
Comment on lines +21 to +42
## Environment

The NDK toolchain must be on `PATH` so cmake can find the compilers and
`llvm-ar`. Boost headers must be discoverable by cmake — either set
`CMAKE_PREFIX_PATH` or symlink them into the NDK sysroot:

```bash
export ANDROID_NDK_HOME=/path/to/android-ndk

# Detect host platform
NDK_HOST="linux-x86_64" # or "darwin-x86_64" on macOS

# Put NDK clang and llvm-ar on PATH
export PATH="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/$NDK_HOST/bin:$PATH"

# Option A: point cmake at your Boost installation
export CMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu/cmake

# Option B: symlink Boost headers into the NDK sysroot
ln -sf /usr/include/boost \
"$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/$NDK_HOST/sysroot/usr/include/boost"
```

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about?

Environment

ANDROID_NDK_HOME selects the NDK that the build uses. If you have more than on NDK installed - Android Studio keeps several - make sure the PATH entry below points at the same one, or cmake and the linker will silently use different toolchains.

export ANDROID_NDK_HOME=/path/to/android-ndk
 
NDK_HOST="linux-x86_64"   # or "darwin-x86_64" on macOS
 
export PATH="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/$NDK_HOST/bin:$PATH"

Boost

cmake has to find the Boost package, and the NDK compiler has to find the
headers. For a distro-installed Boost, with headers in /usr/include/boost,
that takes two steps:

export CMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu/cmake   # Debian/Ubuntu
 
ln -sfn /usr/include/boost \
  "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/$NDK_HOST/sysroot/usr/include/boost"

Which of the two options (A or B) did you take? Neither original option worked alone for Debian/Ubuntu for me.

Without CMAKE_PREFIX_PATH, cmake fails at configure. Without the symlink,
configure succeeds and the build fails later with
'boost/multi_index/hashed_index.hpp' file not found.

If Boost is installed under its own prefix (a source build, or Homebrew on
macOS), pointing CMAKE_PREFIX_PATH at that prefix may be enough on its own,
since the headers are then outside the system include directories. If the
build still reports a missing Boost header, add the symlink as well.


Which original option (A or B) did you take? Neither original option worked alone for me on Debian/Ubuntu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This PR does not require a CHANGELOG entry (e.g. docs, tests, CI changes).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants