Search code examples
gccarmcross-compilingtoolchaingnu-toolchain

Cross compiling stand alone application?


I am trying to cross compiling a stand alone application for arm board and most important I want to compile it without Android.mk framework.

I have following doubt :-

1- Which tool should I use like (arm-eabi or arm-linux-androideabi etc).

2- From where should I download library and toolchain related parts.

3- What are compilation flags should I include for stand alone compilation (completely static).

Please Comment if question is not clear also please add related information that is I missing , detailed information will be appreciated.


Solution

  • Standalone Toolchain part of NDK covers this precisely.

    First of all compiler requires to know where sysroot is located so it can find standard libraries.

    SYSROOT=$NDK/platforms/android-21/arch-arm
    

    and then either you can do

    export CC="$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/ \
    linux-x86/bin/arm-linux-androideabi-gcc-4.8 --sysroot=$SYSROOT"  $CC -o foo.o -c foo.c
    

    and for static compilations just add -static to the invocation.

    Advanced method is about installing a certain toolchain to a directory which then you can invoke directly without specifying the sysroot.