Skip to content

Instantly share code, notes, and snippets.

Last active Dec 10, 2016
What would you like to do?
Script for Building Android Toolchain (both host and target arm-linux-androideabi)
# You need to fix several header error before compiling.
# For more information, please read:
export PWD=`pwd`
export PREFIX=${PWD}/system
export NDK_HOME=/xxx/aosp/android-ndk-r10e
export CROSS_COMPILE=${NDK_HOME}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
export PATH=${NDK_HOME}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:$PATH
export SYSROOT=${NDK_HOME}/platforms/android-21/arch-arm
make distclean
rm */config.cache
sed -i 's/^#include <stdio_ext.h>/\/* #include <stdio_ext.h> *\//' libiberty/fopen_unlocked.c
sed -i 's/^# include <sys\/sysctl.h>/\/* # include <sys\/sysctl.h> *\//' libiberty/physmem.c
ln -s ${NDK_HOME}/platforms/android-21/arch-arm/usr/lib/crtbegin_so.o ld/
ln -s ${NDK_HOME}/platforms/android-21/arch-arm/usr/lib/crtend_so.o ld/
./configure \
--prefix=$PREFIX \
--host=arm-linux-androideabi \
--target=arm-linux-androideabi \
--disable-option-checking \
CFLAGS="-g -I -O2 -mandroid -mbionic -I${NDK_HOME}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9/include -I${SYSROOT}/usr/include/ --sysroot=${SYSROOT} -Wno-error -fPIE" \
LDFLAGS="-L${NDK_HOME}/platforms/android-21/arch-arm/usr/lib -pie" \
CPPFLAGS="-I${NDK_HOME}/platforms/android-21/arch-arm/usr/include/" \
make -j4
mkdir -p $PREFIX
make install
Copy link

heyligengregory commented Apr 21, 2016

This script is helpful but it seems that there is still a problem with "crtbegin_so.o" --> ld/ doesn't exist or am I blind ?


Copy link

mittorn commented Dec 10, 2016

@heyligengregory it exist only during binutils build


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