docs: add manual Android cross-compilation instructions - #210
Conversation
|
Should i add a entry for this change on CHANGELOG ? |
|
I think we should have the instructions with nix in
Just added the |
490e2c8 to
b280ff1
Compare
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.
b280ff1 to
02544d4
Compare
|
Done @alexanderwiederin Github is trolling |
|
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
left a comment
There was a problem hiding this comment.
Nice! I would suggest we add a ci job like this one.
Also suggested something in the environment/boost section - question is inline.
|
|
||
| ## Prerequisites | ||
|
|
||
| Android NDK (r27+ recommended), cmake, and Boost headers installed on the |
There was a problem hiding this comment.
| Android NDK (r27+ recommended), cmake, and Boost headers installed on the | |
| Android NDK (tested with r27.3), cmake, and Boost headers installed on the |
| ## 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" | ||
| ``` |
There was a problem hiding this comment.
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.
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