Skip to content

Instantly share code, notes, and snippets.

@ArrEssJay
Last active December 24, 2015 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArrEssJay/6805400 to your computer and use it in GitHub Desktop.
Save ArrEssJay/6805400 to your computer and use it in GitHub Desktop.
Android.mk NDK makefile to build a simple command-line app linked against a static or shared library Compiler options would suit arm v7a only (eg. Cortex A8). See the NDK doco.
# build executable linked against static lib using NDK
# Usage: <NDK_Location>/ndk-build NDK_PROJECT_PATH=./ NDK_APPLICATION_MK=./Android.mk
# (Assuming 'pwd' is your native code location)
LOCAL_PATH := $(call my-dir)
#prebuilt static library
include $(CLEAR_VARS)
LOCAL_MODULE := foo
LOCAL_SRC_FILES := foo.a
include $(PREBUILT_STATIC_LIBRARY)
#prebuilt shared library
include $(CLEAR_VARS)
LOCAL_MODULE := bar
LOCAL_SRC_FILES := lib_bar.so
include $(PREBUILT_SHARED_LIBRARY)
#application
include $(CLEAR_VARS)
LOCAL_MODULE := myapp
LOCAL_SRC_FILES := myapp.c
#set compiler options for arm-v7a
LOCAL_CFLAGS += -mfpu=vfp -mfloat-abi=softfp
#Choose a different linker, maybe
LOCAL_LDFLAGS := -fuse-ld=mcld
LOCAL_STATIC_LIBRARIES += foo
LOCAL_SHARED_LIBRARIES += bar
include $(BUILD_EXECUTABLE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment