Android NDK, No rule to make target - android

I've seen this question other places, but the answers don't seem to apply to my situation. I've got a .cpp file (not a .c file). I'm getting the error:
make: * No rule to make target jni/native.c', needed byobj/local/armeabi/objs/native/native.o'. Stop. Cirapi_android C/C++ Problem
Here's my Android.mk file (very simple):
LOCAL_PATH:=$(call my-dir)
include $(CLEAR_VARS)
LOCAL_LDLIBS:=-llog
LOCAL_MODULE:=native
LOCAL_SRC_FILES:=native.cpp
include $(BUILD_SHARED_LIBRARY)
I've removed all the extra spaces that solved other's problems. It's complaining about native.c which I don't even have listed in my makefile. Any ideas?
I'm on MacOSX Snow Leopard, Eclipse Juno, NDK r8

Got it to work...not sure what the key was...changed the makefile to..
TOP_LOCAL_PATH:=$(call my-dir)
include $(call all-subdir-makefiles)
LOCAL_PATH := $(TOP_LOCAL_PATH)
include $(CLEAR_VARS)
LOCAL_LDLIBS:=-llog
LOCAL_MODULE:=native
LOCAL_SRC_FILES:=native.cpp
include $(BUILD_SHARED_LIBRARY)
...also removed the .o files from the obj directory...suspected that a clean was not working correctly.

Related

NDK unable to find my module in the NDK_MODULE_PATH - android-ndk-profiler

I am trying to use android-ndk-profiler - https://github.com/richq/android-ndk-profiler
As described in the usage document https://github.com/richq/android-ndk-profiler/blob/master/docs/Usage.md
I unzipped the zip file to $HOME/Documents/Dev
My Android.mk looks like this
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ndkbasics
LOCAL_SRC_FILES := ndkbasics.cpp
LOCAL_LDLIBS := -llog
# compile with profiling
LOCAL_CFLAGS := -pg
LOCAL_STATIC_LIBRARIES := android-ndk-profiler
include $(BUILD_SHARED_LIBRARY)
# at the end of Android.mk
$(call import-module,android-ndk-profiler)
When trying to build using the command
ndk-build NDK_MODULE_PATH=$HOME/Documents/Dev/
I get the error
Android NDK: /Users/hanantha/Documents/Dev/projects/workspaceWeeklyPreso/NdkProfileMethods/jni/Android.mk: Cannot find module with tag 'android-ndk-profiler' in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?
Android NDK: The following directories were searched:
Android NDK:
/Users/hanantha/Documents/Dev/projects/workspaceWeeklyPreso/NdkProfileMethods/jni/Android.mk:16: *** Android NDK: Aborting. . Stop.
Additional points
I have tried setting NDK_MODULE_PATH in my bash_profile
ndk version r10d
Ran the make file in the unzipped folder android-ndk-profiler
It is strange that ndk says the directories that it has searched is empty. What could be going wrong?
I think you have done almost correct process need to change at one place as follow
# at the end of Android.mk
$(call import-module,android-ndk-profiler/jni)
Adding jni in import-module will solve your problem because it's working for me.

target pattern contains no '%'

I tried to build the ndk and get error
/android-ndk-r9/build/core/prebuilt-library.mk:68: *** target pattern contains no '%'. Stop.****
my Android.mk code is :
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
OPENCV_CAMERA_MODULES := on
OPENCV_INSTALL_MODULES := on
#OPENCV_LIB_TYPE:=SHARED
include D:/Books/Java/winx86_01Jan12/OpenCV-2.4.9-android-sdk/sdk/native/jni/OpenCV.mk
LOCAL_SRC_FILES := F_jni.cpp
LOCAL_C_INCLUDES += $(LOCAL_PATH)
LOCAL_LDLIBS += -llog -ldl
LOCAL_MODULE := f
include $(BUILD_SHARED_LIBRARY)
please help Until I resolve my problem.I'm really confused.I tried several ways and I could not solve my issue.
ndk-build invokes make which does not handle the : character in targets well. If your project resides on disk D:, too, then you can refer to OpenCV without the drive letter,
include /Books/Java/winx86_01Jan12/OpenCV-2.4.9-android-sdk/sdk/native/jni/OpenCV.mk
Otherwise you can try
include //D/Books/Java/winx86_01Jan12/OpenCV-2.4.9-android-sdk/sdk/native/jni/OpenCV.mk
include //localhost/D$/Books/Java/winx86_01Jan12/OpenCV-2.4.9-android-sdk/sdk/native/jni/OpenCV.mk
If nothing helps, copy your OpenCV SDK such that you can use a relative path, e.g.
include ../../OpenCV-2.4.9-android-sdk/sdk/native/jni/OpenCV.mk
PS The source of your troubles is probably cygwin somewhere on the PATH. Since November 2011, NDK r7, ndk-build does not need cygwin. OpenCV made the reciprocate step short afterwards. Unfortunately, many developers still need cygwin for their daily work; furthermore, until recently, you still needed cygwin to run ndk-dgb (you have ndk-gdb-py.cmd now!). So my advice is to remove cygwin\bin directory from your PATH before you run ndk-build.cmd. You can easily do it in Project build properties if you use Ecliplse/ADT to build your native code.

including prebuilt libraries in android ndk

After a great deal of pain, I have finally built UHD for android. I use a script that takes a standard UHD package and builds everything with the android tools. I then take the resulting libraries and include files and put them under the jni directory. This is what my directory structure looks like
> jni
> uhd
- Android.mk
> lib
- libuhd.so
- libuhd.so.003
- libuhd.so.003.005
> pkgconfig
- uhd.pc
> include
- *.hpp
Here is my Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := uhd
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_SRC_FILES := lib/libuhd.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
Everything build nicely when I include it in my project. The problem comes in when I put it on the device. The app immediately crashes. Looking at the log file gives me the following message
E/dalvikvm(20135): dlopen("/data/app-lib/com.myproject-1/libmyproject.so") failed: dlopen failed: could not load library "libuhd.so.003" needed by "libmyproject.so"; caused by library "libuhd.so.003" not found
So (no pun intended) I changed the LOCAL_SRC_FILES to be the libuhd.so.003, but android throws an error telling me that I am not allowed to do that. A prebuilt shared library must end in .so, not .so.003. I have also tried copying the library to the /libs folder in the base directory of the project, but that doesn't seem to work either.
How can I either change the library name or change what myproject.so is looking for?
Thanks.

Android.mk will compile .c source but not .cpp

I have an Android.mk file that compiles my NDK C code just fine:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := galib
LOCAL_SRC_FILES := galib.c tables-lr35-contam.c tables-lr35-perf.c
LOCAL_CFLAGS := -DTARGET_ANDROID=1
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
include $(BUILD_SHARED_LIBRARY)
I'd like to call the first source galib.cpp instead of .c because that's the name I need it to be when compiling it in the WPF environment. It really is just C code but to make a DLL I have to name it .cpp for it to handle the __declspec(dllexport) stuff properly.
However, when I rename it galib.cpp and change the .mk file to say the same and try to build it for Android, I get the error:
$ ndk-build
make: *** No rule to make target `/cygdrive/c/apk/adev/android/etold/jni/galib.c',
...needed by `/cygdrive/c/apk/adev/android/etold/obj/local/armeabi/objs/galib/galib.o'. Stop.
as though it still wants a .c file for some reason. I also tried "ndk-build -B" in case there's something left over from the .c build, but that results in the same error. Any idea why? Thanks!
I know that you asked that long time ago. But anyway - for other people like me:
I tackled into this problem too just now.
For some reason clean build doesn't do the job even when you change the sources list at LOCAL_SRC_FILES.
I had to navigate to \obj\local\armeabi\objs\ within the project and clean .o files manually.
After that it compiled fine.

Android NDK: No rule to make target

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.
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.
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.
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.
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
If there are any syntax error in Android.mk file, no rule to make target error will be there.
I had the same problem.
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.

Categories

Resources