How to specify directory for NDK_MODULE_PATH - android

I am having a trouble with this simple task for last couple of hours.
I have ndk-modules directory in root of my Android project and I have following in my Android.mk of jni folder
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
NDK_MODULE_PATH := $(LOCAL_PATH)/../ndk-modules
...
$(call import-module,mymodule)
When I build the mk file, I got
Android NDK: /MyApp/jni/Android.mk: Cannot find module with tag 'mymodule' in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?
What am I doing wrong here? How can I specify the path correctly?
UPDATE:
The specification was right. I had a problem in mymodule directory. Sorry for the confusion.

NDK_MODULE_PATH must be in your path. I wanted to specify it in my Android.mk file so I added this line before the import-module line:
$(call import-add-path,my_relative_path)

In my case, I fixed it by realizing NDK searches for:
$NDK_MODULE_PATH/module_name/Android.mk
But my "module_name" is an Eclipse project where Android.mk is under:
$NDK_MODULE_PATH/module_name/jni/Android.mk
So NDK cannot find it. I fixed it by:
Move module_name/jni/* to "somewhere/module_name".
In Android.mk:
$(call import-add-path, /path/to/somewhere)
$(call import-module,module_name)

$(call import-module,mymodule) will search $NDK_MODULE_PATH/mymodule, you may set path to top level of the project or create a folder named mymodule under ndk-modules

Related

Android.mk Build problem with sub directories

I had trouble with Android.mk in PROJECT_FOLDER directory,
//Android.mk
LOCAL_PATH:= $(call my-dir)
include $(call all-makefiles-under,$(LOCAL_PATH))
and in PROJECT_FOLDER, say there were SUB_DIR1 and SUB_DIR2
in SUB_DIR1, I had Android.mk file, but in SUB_DIR2 I did not.
And I've found out that build system doesn't go through SUB_DIR2 but SUB_DIR1,
but I am not sure why.
My guess is that my Android mk goes through every sub directory under Android.mk, searching for another Android.mk or Android.bp,
and if one directory does not have Android.mk at top, it just assumes that the directory is unrelevant?
could anyone enlighten me?

Adding external .h files to NDK project in Windows

I have added ndk plugin in Eclipse.
I have imported a NDK project in Eclipse.
But projects requires external .h file from the system, so I have added that folder where .h files files resides by
right click on project-> c/C++ General->Paths and symbols->then click on
include and then click add and given path of that folder
also checked all configurations and all languages.
still when I build the project from Command prompt by moving to path where my project is , then ndk-build I am getting for .h file no such file or directory error.
How can I resolve this issue??
Please help...
Please refer to documentation of LOCAL_C_INCLUDES variable
what you did to add the reference the external headers was only for eclipse, so it correctly resolves all the symbols and files references.
You also need to properly add a reference to these .h inside your ndk configuration files, ie inside Android.mk.
Use LOCAL_C_INCLUDES := path/to/headers in your module, like in this sample Android.mk file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := main.c
LOCAL_MODULE := mymodule
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../includes
include $(BUILD_SHARED_LIBRARY)
If your .h files are part of a prebuilt module your own module depends on, use LOCAL_EXPORT_C_INCLUDES inside the prebuilt module instead of LOCAL_C_INCLUDES inside yours.

Android makefile call import path variable value

In an android makefile I have a following line
$(call import-add-path,/Users/bruno/Dev/cocos2d-x-2.1.5)
Now, I am working with several people and having that line is not very people-friendly. I have tried defining that path in an environment variable but it gets ignored when I add it to the call import-add-path line. I output the variable as a warning and the makefile obviously has the vatiable present:
$(warning $(NMP)) # outputs: jni/Android.mk:29: /Users/bruno/Dev/cocos2d-x-2.1.5
$(call import-add-path,$(NMP))
How can I make this work so that is multiple developers friendly?
Edit: Eclipse on OSX, building a cocos2d-x 2.1.5 TestCpp project, android NDK r10c. The error message I get is actually about the missing ABI and asking me if I have set the NDK_MODULE_PATH variable properly and it happens only on a debug build (perhaps GDB makes a difference?).
In the end this setup worked for me:
LOCAL_PATH := $(call my-dir) # ./Project/proj.android/jni/ folder
...
IMPORT_PATH := $(LOCAL_PATH)/../../.. # ./ this gets me to where the modules are located
$(call import-add-path, $(IMPORT_PATH))
$(call import-add-path, $(IMPORT_PATH)/cocos2dx/platform/third_party/android/prebuilt)
$(call import-module,cocos2dx) # ./cocos2dx
$(call import-module, ... etc.
I could not pass environment variables through Eclipse to the ndk-build, but it worked if I called import-add-path with a value relative to $(call my-dir). This should work with multiple developers as well.

Android NDK: code under sub-directory isn't built at all

In my Android NDK project, I have the following structure:
jni/
Android.mk
... (more source files)
new-lib/
Android.mk
... (more source files)
In the top level Android.mk I have include $(call all-subdir-makefiles) as the last line. I suppose now all the native codes including those under new-lib/ should get built when run ndk-build.
But when I run ndk-build command under project root path, only the top level native codes get built, the native code in subdir new-lib/ isn't built at all. Why?
I only work with one Android.mk in which I define all include folders, but I think here you'll find what you need. For what I understand, you need to make sure you are using the LOCAL_PATH in all your Android.mk files like this:
LOCAL_PATH := $(call my-dir)

Android NDK, No rule to make target

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.

Categories

Resources