1

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!

3
  • You need to add submodule Android.mk codes as well. Commented Aug 13, 2013 at 11:46
  • @user2359247 Yes, I have added the Android.mk in the submodule. And it contains the build info. Update the Android in the submodule. Commented Aug 13, 2013 at 11:50
  • why don't you just use "include $(LOCAL_PATH)/submodule1/Android.mk" in your main Android.mk inside main module? Commented Aug 13, 2013 at 12:44

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

4 Comments

I have tried the all-subdir-makefiles. The errors also appeared. I have updated the Android.mk in subfolder. Is there anything wrong with the Android.mk?
@Bob are you using MAC or Linux ?
check whether you have given Read-Write permission to your project folder .
Yes, I have RW permission.
0

Have you tried something like:

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

2 Comments

make: *** No rule to make target /home/../workspace/jni/submodule//submodule/sub.c', needed b y /home/../workspace/obj/local/armeabi/objs//submodule/sub.o'. Stop.
Could you please try this one

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.