2

How can I compile third party libraries with the android NDK? I am compiling a wrapper which implements the JNI functions as a shared lib, which depends on another 3rd party lib (HTK). I don't know how to setup the makefile. The following does not work:

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

include HTKLib/Android.mk

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

LOCAL_MODULE    := gaitfuncs
LOCAL_SRC_FILES := gaitfuncs.c
%LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog

include $(BUILD_SHARED_LIBRARY)

The second makefile should then build a static lib which my shared lib links to. How can I include this subdir makefile properly? Is this the correct way of doing it? And as a bonus: Are there wildcards for the LOCAL_SRC_FILES variable to take all files ending in .c for example.

Thanks!

user363362
  • 121
  • 1
  • 5

2 Answers2

10

I found a solution:

JNIPATH := $(call my-dir)
LOCAL_PATH := $(JNIPATH)

include $(call all-subdir-makefiles)

LOCAL_PATH := $(JNIPATH)
include $(CLEAR_VARS)

LOCAL_MODULE    := gaitfuncs
LOCAL_SRC_FILES := gaitfuncs.c
LOCAL_STATIC_LIBRARIES := htk

include $(BUILD_SHARED_LIBRARY)

Calling the CLEAR_VARS function before calling the subdir-makefiles function wasn't exactly elegant ;)

user363362
  • 121
  • 1
  • 5
0

In the documentation.html in Android NDK folder,

take a look at the macro function "my-dir"

Returns the path of the last included Makefile, which typically is the current Android.mk's directory. This is useful to define LOCAL_PATH at the start of your Android.mk as with:

 LOCAL_PATH := $(call my-dir)

and the macro function "all-subdir-makefiles"

Returns a list of Android.mk located in all sub-directories of the current 'my-dir' path.

onmyway133
  • 45,645
  • 31
  • 257
  • 263