Bob Sun
Bob Sun

Reputation: 131

How to use ndk-build build the source files in different folders?

I know that to build so file, I should put the source file in /jni/ folder. But how can I build separate so in different folders.

For example, the structure of my project:

/jni/Android.mk
/jni/submodule1/Android.mk
/jni/submodule1/sub1.c
/jni/submodule2/Android.mk
/jni/submodule2/sub2.c

I have tried to write this in Android.mk in the top level:

$(LOCAL_PATH) :=$(call all-makefiles-under)

then wrote make info in Android.mk in submodule

the error is:

ndk-build 
make: *** No rule to make target `/home/../workspace/jni/sub.c', needed b
y `/home/../workspace/obj/local/armeabi/objs/submodule/sub.o'.  Stop.

Can someone give me a solution? Thank you!

Update 1: The code of Android.mk in submoudle:

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

 LOCAL_SRC_FILES := sub.c 

 LOCAL_C_INCLUDES := $(LOCAL_PATH)

 LOCAL_MODULE := sub
 LOCAL_LDLIBS := -ldl -llog
 LOCAL_STATIC_LIBRARIES := libc

 LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
 LOCAL_MODULE_TAGS := debug
 include $(BUILD_EXECUTABLE)

SOLVED:

I should use ndk-build in the root directory, but not in jni directory. Thanks all of you!

Upvotes: 1

Views: 3328

Answers (2)

dharmendra
dharmendra

Reputation: 7881

You should try include $(call all-subdir-makefiles) rather then $(LOCAL_PATH) :=$(call all-makefiles-under) in main Android.mk and make folder under jni folder with there separate c files and Android.mk files

Upvotes: 1

Shamim Ahmmed
Shamim Ahmmed

Reputation: 8383

Have you tried something like:

LOCAL_PATH := $(call my-dir)
LOCAL_SRC_FILES := /submodule1/sub1.c

Upvotes: 0

Related Questions