Android:NDK:Toolchains
lastmod 2018-08-17created 2016-06-241 edits
Installing the Android NDK and extracting the toolchain
Download and install the NDK.
$ tar -jxvf android-ndk-r6-linux-x86.tar.bz2
$ android-ndk-r6/build/tools/make-standalone-toolchain.sh --platform=android-8 --install-dir=/opt/android-8-toolchain
Or
$ cd android-ndk-r6/build/tools
$ ./make-standalone-toolchain.sh --ndk-dir=/home/ziippy/Android/android-ndk-r6 --platform=android-8 --install-dir=/opt/android-8-toolchain
This puts the toolchain in /opt/android-8-toolchain. Build with it. To compile sample code, assuming there is a test.cpp, create a Makefile as follows.
ARM_COMPILE = /opt/android-8-toolchain/bin/arm-linux-androideabi-
CC = g++
ARM_CC = $(ARM_COMPILE)g++
ARM_INCLUDES = -I /opt/android-8-toolchain/sysroot/usr/include
CFLAGS = -O2 -Wall -D_LINUX -fno-strict-aliasing -D_COLOR_LOG
BINS = test
arm:
$(ARM_CC) $(CFLAGS) -o test_arm test.cpp $(ARM_INCLUDES)
For reference, to register it in the environment variables, add the path to /etc/profile.
Then you can simply do this