Wednesday, May 8, 2013

Get standalone ARM Toolchain for Android from NDK

This tutorial shows how to get standalone ARM toolchain for Android.

Actaully... you can get standalone ARM toolchain by
$ sudo apt-get install gcc-arm-linux-gnueabi
That's it.. no need to continue reading..

It used to be very complex procedure to build a toolchain, but luckily in NDK, google already prepare it ready for you. Follow the steps below, you will get your standalone toolchain (cross compiler) for ARM in 10min.

1. Download the Android NDK from
    and untar it

2. There is a "toolchain" folder in the ndk, but I find that if I use that directly, there will be errors like:
    stdio.h:50:23: fatal error: sys/cdefs.h: No such file or directory
    If you go to the "docs" folder in the ndk folder, in STANDALONE-TOOLCHAIN.html, it explains in detail how to get a standalone toolchain from the ndk.
    For your convenience, I post the command here:
    First go to your ndk folder
    $ ./build/tools/ --platform=android-9 --install-dir=~/my-android-toolchain-dir

    The --platform=android-9 specify the Android API level you want to support; --install-dir specifies the directory where you want to put the toolchain, if you omit the --install-dir, it will create a tar.bz2 file for you, and you can untar it anywhere you want -- which is better, i think : )
    If you are using 64bit Linux, you will have to add --system=linux_x86_64 in the command above

3. Try to compile a HelloWorld program using the new toolchain, and enjoy!

1 comment:

  1. can apt-get install it on the device?
    eg via a Debian installation the device (installed by an app) that runs alongside Android (not dual boot - its still Android underneath - but Debian has apt-get)

    and can adb work locally (from the device itself) ?-

    and most urgently fo me right now - is there a way to use the device headless and remotely see the display?
    I can't see the display because my hdmi->vga box died and i don't have a hdmi monitor - even low-res would do ..I just need some way to be able to use the android gui if need to start/stop an Android app or change settings or anything else that I can't find a way to do on the shell)