I'm compiling native sources and adding the dependencies with .a libs and those relative header files with the following structure.
/jni/
Android.mk
LOCAL_PATH := $(call my-dir)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog
LOCAL_MODULE    := ndk1
LOCAL_SRC_FILES := native.c
LOCAL_STATIC_LIBRARY := mschema 
include $(BUILD_SHARED_LIBRARY)
native.c
/jni/prereqs/
Android.mk
LOCAL_PATH := $(call my-dir)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
--Used to call the sub-folders mk files
/jni/prereqs/mschema/
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    :=mschema
LOCAL_SRC_FILES :=libmschema.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)
libmschema.a
/jni/prereqs/mschema/include
Header files. (.h)
But while trying to ndk-build (NDK5) I got the following error.
marcos@marcos-AY675AA-AC4-s5320br:~/dev/workspace/rmsdk.native.wraper$ ndk-buildmake:
 *** No rule to make target `/home/marcos/dev/workspace/rmsdk.native.wraper/jni/prereqs/mschema/native.c', needed by `/home/marcos/dev/workspace/rmsdk.native.wraper/obj/local/armeabi/objs/ndk1/native.o'.  Stop.
While typing I noted the error is about /home/marcos/dev/workspace/rmsdk.native.wraper/jni/prereqs/mschema/native.c' and actually this file is under/home/marcos/dev/workspace/rmsdk.native.wraper/jni/native.c', what's wrong in my make files?
The problem could be avoided by changing the first Android.mk to the following:
LOCAL_PATH := $(call my-dir)
include $(call all-subdir-makefiles)
LOCAL_PATH :=/home/marcos/dev/workspace/rmsdk.native.wraper/jni
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog
LOCAL_MODULE    := ndk1
LOCAL_SRC_FILES := native.c
LOCAL_STATIC_LIBRARY := mschema
include $(BUILD_SHARED_LIBRARY)
But it looks wrong. Is there a better approach?
From the Docs in NDK 5, the solution is to create a local variable..
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)
IMPORTANT NOTE: Due to the way GNU Make works, this really returns
the path of the *last* *included* *Makefile* during the parsing of
build scripts. Do not call my-dir after including another file.
So.. to solve this problem I change my Android.mk to the following.
 LOCAL_PATH := $(call my-dir)
 MY_PATH := $(LOCAL_PATH)
 include $(call all-subdir-makefiles)
 include $(CLEAR_VARS)
 LOCAL_PATH := $(MY_PATH)
 LOCAL_LDLIBS := -llog -ldl
 LOCAL_MODULE    := rmsdk
 LOCAL_SRC_FILES := native.c
 include $(BUILD_SHARED_LIBRARY)
And its works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With