Cross-compile autotools library for Android / arm-linux-androideabi I stick that in ~/bin/, chmod +x, and then run it in place of "./configure" in my project. Then a make and make install later, the prefix contains libraries built for android. Neato eh?
#!/bin/sh | |
# I put all my dev stuff in here | |
export DEV_PREFIX=$HOME/Dev/ | |
# Don't forget to adjust this to your NDK path | |
export ANDROID_NDK=${DEV_PREFIX}/android-ndk-r8d/ | |
export CROSS_COMPILE=arm-linux-androideabi | |
# I chose the gcc-4.7 toolchain - works fine for me! | |
export ANDROID_PREFIX=${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.7/prebuilt/darwin-x86 | |
# Apparently android-8 works fine, there are other versions, look them up | |
export SYSROOT=${ANDROID_NDK}/platforms/android-8/arch-arm | |
export CROSS_PATH=${ANDROID_PREFIX}/bin/${CROSS_COMPILE} | |
# Non-exhaustive lists of compiler + binutils | |
# Depending on what you compile, you might need more binutils than that | |
export CPP=${CROSS_PATH}-cpp | |
export AR=${CROSS_PATH}-ar | |
export AS=${CROSS_PATH}-as | |
export NM=${CROSS_PATH}-nm | |
export CC=${CROSS_PATH}-gcc | |
export CXX=${CROSS_PATH}-g++ | |
export LD=${CROSS_PATH}-ld | |
export RANLIB=${CROSS_PATH}-ranlib | |
# This is just an empty directory where I want the built objects to be installed | |
export PREFIX=${DEV_PREFIX}/android/prefix | |
# Don't mix up .pc files from your host and build target | |
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig | |
# You can clone the full Android sources to get bionic if you want.. I didn't | |
# want to so I just got linker.h from here: http://gitorious.org/0xdroid/bionic | |
# Note that this was only required to build boehm-gc with dynamic linking support. | |
export CFLAGS="${CFLAGS} --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include -I${DEV_PREFIX}/android/bionic" | |
export CPPFLAGS="${CFLAGS}" | |
export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib -L${ANDROID_PREFIX}/lib" | |
./configure --host=${CROSS_COMPILE} --with-sysroot=${SYSROOT} --prefix=${PREFIX} "$@" |
This comment has been minimized.
This comment has been minimized.
z3ntu
commented
Dec 19, 2015
Thank you very much for this! |
This comment has been minimized.
This comment has been minimized.
arunkk-git
commented
Jun 28, 2017
nice script. |
This comment has been minimized.
This comment has been minimized.
mohabouje
commented
Jul 9, 2017
Awesome script! You save hours of time! |
This comment has been minimized.
This comment has been minimized.
samonkey-zouyingjun
commented
Mar 17, 2018
233,nice! |
This comment has been minimized.
This comment has been minimized.
sandeepkumarmishra354
commented
Apr 8, 2018
how to use this script..? |
This comment has been minimized.
This comment has been minimized.
malayarout91
commented
Nov 20, 2018
This script is not working for me getting the below error. checking whether the C compiler works... no |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
jeliser commentedNov 9, 2015
Awesome script! I'm having to cross compile a bunch of libs and this worked liked a charm!