kaneda
kaneda

Reputation: 6187

How to compile a native library using NDK build system from outside an app project?

I'm trying to compile a native lib using ndk tools outside of any project. I am using the following at the terminal:

ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk APP_PLATFORM=android-9  V=1

I also have at the same directory of Android.mk an Application.mk

APP_BUILD_SCRIPT := $(call my-dir)/Android.mk
NDK_PROJECT_PATH := $(call my-dir)
APP_PLATFORM := android-9
APP_ABI := armeabi-v7a

I would like to use instead of passing those flags from the command line. The build system is ignoring my Application.mk though. What am I doing wrong? Or else might what I'm trying to do (compiling a library from outside of an app project) not be possible.

Upvotes: 2

Views: 2436

Answers (1)

Ahmed Hegazy
Ahmed Hegazy

Reputation: 12615

Compiling a library from outside of an application project is possible.

You just missed setting NDK_APPLICATION_MK to your Application.mk file.

ndk-build NDK_PROJECT_PATH=. NDK_APPLICATION_MK=Application.mk APP_BUILD_SCRIPT=Android.mk

A simpler way to do that is to put the make files(Android.mk, Application.mk) in a folder named jni/ that what the build system expects to find them. And you will just call ndk-build on the project root folder to build your library.

Upvotes: 4

Related Questions