Which compiler does Android NDK use? Which compiler does Android NDK use? android android

Which compiler does Android NDK use?


Regarding NDK r8d it can be modified in 2 ways (see Andriod ndk):

  • For ndk-build, export the NDK_TOOLCHAIN_VERSION=4.7 variable or add it to Application.mk.
  • For standalone builds, add the --toolchain= option to make-standalone-toolchain.sh--toolchain=arm-linux-androideabi-4.7

Default compiler is set in ndk/build/core/setup-toolchain.mk (see NDK_TOOLCHAIN and NDK_TOOLCHAIN_VERSION)


The NDK itself invokes a customized cross-compiler built on the arm-eabi-gcc compiler. There are examples out there of people creating custom toolchains using bog-standard GCC implementations with support for ARM instruction sets but that's way out of my league. Most of the stuff I've read in the past always discussed using the toolchain included with the NDK to compile native code.

Corollary: Most of the people who have complained and have had to make their own toolchain have been people that were upset with the (supposed) sub-par C++ support of the NDK toolchain's compiler. I can't speak to this because some of the articles were older and Android changes so rapidly. It also hasn't been an opinion that seems to pop up all too frequently.


GCC is deprecated in favor of clang as of NDK 11 (March 2016)

Mentioned on the official revision history: https://developer.android.com/ndk/downloads/revision_history.html

How to switch between compilers is asked at:

And you can check it easily with:

enum CONSTEXPR {N = 256};char s[N];#ifdef __clang__        snprintf(s, N, "%s", "clang" __clang_version__);#else# ifdef __GNUC__        snprintf(s, N, "%s %d.%d.%d", "gcc", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);# endif#endif

then just log s or return it to a TextView.