Skip to content

Instantly share code, notes, and snippets.

@z3ntu
Last active December 5, 2018 12:57
Show Gist options
  • Save z3ntu/ad46cb6c40bc59b3ae69 to your computer and use it in GitHub Desktop.
Save z3ntu/ad46cb6c40bc59b3ae69 to your computer and use it in GitHub Desktop.
Compile applications for Android
  1. Set your PATH so the Android NDK tools (arm-linux-androideabi-cpp, arm-linux-androideabi-gcc, and friends) are on PATH:
  $ echo $PATH
/opt/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin:
  /opt/android-sdk-macosx/tools/:/opt/android-sdk-macosx/platform-tools/:
  /opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:
  /opt/X11/bin:/usr/local/MacGPG2/bin
  1. Ensure ANDROID_NDK_ROOT is set (this is an Android requirement, see https://groups.google.com/d/msg/android-ndk/qZjhOaynHXc/Szy_KYY9GcwJ):
  $ echo $ANDROID_NDK_ROOT
  /opt/android-ndk-r9
  1. Export the tools:
  export CPP=arm-linux-androideabi-cpp
  export CC=arm-linux-androideabi-cc
  ...
  export LD=arm-linux-androideabi-ld
  ...
  1. Export CPPFLAGS, CFLAGS, and CXXFLAGS with SYSROOT (some autotools tests don't honor the config option):
  $ echo $ANDROID_SYSROOT
  /opt/android-ndk-r9/platforms/android-14/arch-arm
  export CPPFLAGS="--sysroot=$ANDROID_SYSROOT"
  export CFLAGS="--sysroot=$ANDROID_SYSROOT"
  export CXXFLAGS="--sysroot=$ANDROID_SYSROOT"
  1. Configure as follows (--build=arm-android breaks config):
  $ ./configure --host=x86_64-darwin --build=arm --with-sysroot=$ANDROID_SYSROOT
  checking build system type... arm-unknown-none
  checking host system type... x86_64-pc-none
  checking for a BSD-compatible install... /usr/bin/install -c
  checking whether build environment is sane... yes

from https://lists.gnu.org/archive/html/autoconf/2013-10/msg00004.html

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