I'm writing ARM NEON-based code for an Android application and I was struggling with certain compiler flags not being recognized. I later realized that support for those flags was only added quite recently and that my GCC version is older. I'm doing the whole thing on Windows and am limited by what versions Cygwin has to offer. Here's my question: before I go and try to build GCC 4.6.0 on my Windows machine and make Cygwin like it, will it work for me or does the NDK use its own version of the GCC and my upgrade will not at all affect it? If it does, is it possible to tell it to use a different compiler?
3 Answers
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)

- 181
- 1
- 2
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.

- 7,181
- 1
- 38
- 46
-
4It probably is just a bog-standard GCC, but built with the correct options set. In theory, `gcc -v` output should show a line `Configured with: ...` showing how GCC was built. Replace `gcc` with the matching `some-prefix-gcc` in some `bin` directory of the NDK of course. – rubenvb Jul 06 '11 at 21:23
-
@rubenvb Most likely. But since I can't speak for Google I can't say that with any level of confidence. – Doug Stephen Jul 06 '11 at 21:26
-
3You can download the NDK, and there will be a build/tools/toolchain-patches folder, with mostly "trivial" GCC build patches to work with Android's system library. So yeah, plain GCC it (almost) is. – rubenvb Jul 07 '11 at 09:58
-
android ndk changed to use clang, so this answer is no longer correct – trampster Mar 28 '20 at 03:59
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:
- How to switch between gcc and clang in Android NDK Revision 11?
- Latest C++11 features with Android NDK
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
.

- 1
- 1

- 347,512
- 102
- 1,199
- 985