Skip to content

Fix: Resolve Android cross-compilation failure (Issue #458)#494

Open
dyrpsf wants to merge 1 commit into
uber:masterfrom
dyrpsf:fix-android-cross-compile
Open

Fix: Resolve Android cross-compilation failure (Issue #458)#494
dyrpsf wants to merge 1 commit into
uber:masterfrom
dyrpsf:fix-android-cross-compile

Conversation

@dyrpsf

@dyrpsf dyrpsf commented Jul 7, 2026

Copy link
Copy Markdown

Fixes #458.

The Problem:
When users attempt to compile h3-py for Android using Buildozer / python-for-android, the build fails at runtime with ImportError: dlopen failed: ... is for EM_X86_64 (62) instead of EM_AARCH64 (183).
Because p4a relies on standard pip install without explicitly passing a CMake toolchain file to scikit-build-core, CMake defaults to building host binaries (x86_64) instead of respecting the target NDK environment.

The Solution:
Added a minimal, non-intrusive environment check in the root CMakeLists.txt just before the project() declaration. If the standard $CC environment variable contains android (which is standard behavior for python-for-android), it automatically sets CMAKE_SYSTEM_NAME to Android.

This forces CMake into cross-compilation mode, allowing it to correctly link against the ARM64 Android NDK without interfering with standard desktop builds (Linux/Mac/Windows).

@dyrpsf dyrpsf mentioned this pull request Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

h3 on Android error

1 participant