As of NDK r8d, this can be solved in a much simpler way.
-
Create a project with the following directory hierarchy:
project/ jni/ Android.mk Application.mk *.c, *.cpp, *.h, etc.
-
Fill in Android.mk with the following content. The most important thing is the last line. Check the NDK doc for the meaning of the other variables.
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := name-of-your-executable LOCAL_SRC_FILES := a.cpp b.cpp c.cpp etc.cpp LOCAL_CPPFLAGS := -std=gnu++0x -Wall -fPIE # whatever g++ flags you like LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog -fPIE -pie # whatever ld flags you like include $(BUILD_EXECUTABLE) # <-- Use this to build an executable.
-
Go to the
project/
directory, and simply typendk-build
The result will be placed in
project/libs/<arch>/name-of-your-executable
.