Home > Android Dev > Compile Static Library only using NDK

Compile Static Library only using NDK

In order to build Static library only follow the below steps

If you have multiple libs to build then make Android.mk file for each library  and call those .mk files in the root Android.mk file. On how to write Android.mk file refer Android NDK docs folder

1.    xxxxx/jni/lib1/Android.mk

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE    :=lib1

LOCAL_SRC_FILES :=aaa.c \
bb.c \
include $(BUILD_STATIC_LIBRARY)

2. xxxxx/jni/lib2/Android.mk

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE    :=lib2

LOCAL_SRC_FILES :=asdf.c \
qwert.c \

include $(BUILD_STATIC_LIBRARY)

3. /jni/Android.mk

MY_JNI_FOLDER := $(call my-dir)
include $(MY_JNI_FOLDER)/lib1/Android.mk
include $(MY_JNI_FOLDER)/lib2/Android.mk

Now create another file Application.mk

APP_MODULES        := lib1 lib2 // Note that each module  specified here will perform a force build, which yields lib1.a and lib2.a
APP_OPTIM        := release
APP_ABI          := armeabi armeabi-v7a

Now, type build using ndk-build script

xxxxx@NHPC /cygdrive/c/android-ndk-r4b/samples/hello-jni/jni
$ ../../ndk-build

Advertisements
Categories: Android Dev
  1. August 17, 2010 at 7:03 pm

    […] Android Dev ← Compile Static Library only using NDK […]

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: