Android NDK: No rule to make target
Asked Answered
P

6

53

I'm trying to build a simple Android application using NDK. Here are the contents of my Android.mk

LOCAL_PATH := $(call my-dir)  

include $(CLEAR_VARS)  

LOCAL_LDLIBS := -llog  

LOCAL_MODULE    := myNDK
LOCAL_SRC_FILES := native.c

include $(BUILD_SHARED_LIBRARY)

And when I'm running ndk-build I get:

make: * No rule to make target '/native.c', needed by '/Users/ivan/Documents/workspace/TestNDK/obj/local/armeabi/objs/myNDK/native.o'. Stop.

So the problem is obviously that make is searching the source files in the root directory and if I copy native.c to my root folder everything works perfectly.

The question is: what should I specify in my Android.mk to set the LOCAL_PATH to my working jni folder.

Potpourri answered 5/6, 2011 at 13:2 Comment(0)
P
89

OK, I've solved my issue, and the reason was very strange: the problem is in the first line

'LOCAL_PATH := $(call my-dir)____'

It had several spaces in the end (I've replaced them with '_'). If you remove them everything works just fine.

Potpourri answered 5/6, 2011 at 15:7 Comment(8)
Yes, it definitely helped someone! My hair thanks you (I was about to start pulling it in frustration)! :)Gossamer
Good catch! It would be nice to report this as an Android bug, since it still occurs with the NDK revision 7.Freemanfreemartin
I really wonder how this happens! Thanks a ton for the solution!Alt
Don't know about you but I copy pasted from a tutorial which obviously contains some sneaky white space. Good catch.Joacimah
Great catch. helped me a lot. ThanlksBareilly
Unbelievable, This is a bug of Android NDK. It taked me some unnecessary days. -1 to ANDROIDRefute
I submitted a bug report: code.google.com/p/android/issues/detail?id=42841Nard
Retardation beyond belief.. Punishing developers for the most inexplicable reason ever.. definitely -1 to AndroidAlidaalidade
G
2

On Mac OS X using android-ndk-r9 64 bit, remove white spaces from the NDK path. That fixed the No rule to make target error for me

Not exactly an answer for OP, but I guess it can save others from wasting their time.

Goglet answered 19/8, 2013 at 15:56 Comment(0)
L
2

Another problem that I found that causes this error is that the

LOCAL_SRC_FILES := native.c

and

LOCAL_MODULE    := native

use the same name. I'm not sure why this causes an error, as the code should be generated in different locations as native.o, native.od, and native. But, apparently it does.

I found this out while trying to compile hello.c to hello. Once I changed hello.c to main.c, everything compiled properly.

Lamrouex answered 18/12, 2016 at 8:11 Comment(0)
C
1

Make sure LOCAL_PATH is at the top of the Android.mk else it won't work due to GNU Compiler syntax

Android.mk

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

Also can have ifeq/endif prior to this if need the ndk-major-at-least shorten path or function defines

Cajun answered 20/7, 2021 at 6:34 Comment(0)
A
0

If there are any syntax error in Android.mk file, no rule to make target error will be there.

I had the same problem.

Aramanta answered 13/3, 2015 at 4:38 Comment(0)
M
0

I have faced this issue when there is a spelling mistake in the root directory name.

Example: My path should have been:

 include $(phone-root-dir)/test/test.mk

but there is spelling mistake as shown

include $(lphone-root-dir)/test/test.mk

Once I corrected spelling mistake it worked fine.

Mechanotherapy answered 23/12, 2019 at 11:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.