[cfe-dev] Clang & Android

Evgeniy Stepanov eugeni.stepanov at gmail.com
Mon May 21 07:42:20 PDT 2012


with the recent changes to the Clang driver, it is now possible (and,
in fact, very easy) to build native libraries for Android apps with

Here is how you setup a Clang-based toolchain for Android NDK:

1. Grab the NDK at http://developer.android.com/sdk/ndk/index.html and
unpack it.
2. Build Clang ToT with --target=arm-linux-androideabi.
3. Find the GCC-based ARM toolchain in
<ndk>/toolchains/arm-linux-androideabi-4.4.3, and copy Clang build
over it:
cp Release+Asserts/bin/clang $TOOLCHAIN/prebuilt/linux-x86/bin/
cp -r Release+Asserts/lib/clang $TOOLCHAIN/prebuilt/linux-x86/lib/
ln -sf clang $TOOLCHAIN/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc
ln -sf clang $TOOLCHAIN/prebuilt/linux-x86/bin/arm-linux-androideabi-g++

And that's all! Now ndk-build will use Clang for "armeabi" and
"armeabi-v7a" platforms.

If you choose to keep the original toolchain, ndk-build has a handy
switch NDK_TOOLCHAIN= (ex., NDK_TOOLCHAIN=arm-linux-androideabi-4.4.3)
to pick one or the other.

More information about the cfe-dev mailing list