Switching NDK toolchains
A toolchain is a set of tools that are used to build your project. A toolchain usually consists of a compiler, an assembler, and a linker. Android NDK comes with different toolchains—GCC and Clang—of different versions. It has a convenient and simple way to switch between them.
Getting ready
Look through the list of the available toolchains before proceeding. You can find all the available toolchains in the $(NDK_ROOT)/toolchains/
folder.
How to do it...
The parameter NDK_TOOLCHAIN_VERSION
in Application.mk
corresponds to one of the available toolchains. In NDK r9b, you can switch between three GCC versions—4.6, and 4.7, which are marked as deprecated and will be removed from the next NDK releases, and 4.8. And two Clang versions—Clang3.2, which is also marked as deprecated, and Clang3.3. The default toolchain in the NDK r9b is still GCC 4.6.
Starting from the NDK r8e, you can just specify clang
as the value of NDK_TOOLCHAIN_VERSION
. This option will select the most recent version of the available Clang toolchain.
There's more...
The toolchains are discovered by the $(NDK_ROOT)/build/core/init.mk
script, so you can define your own toolchain in a folder named <ABI>-<ToolchainName>
and use it in Application.mk
.