user1477339
user1477339

Reputation: 115

ndk-build can't find files under jni directory

I have a very simple test project. Basically one native c file under jni (jni is under the root of the project, in the same directory as 'src' 'res' etc). The make file is the basically the simplest:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := native
LOCAL_SRC_FILES := native.c
include $(BUILD_SHARED_LIBRARY)

Error message is: make: * No rule to make target ` '/native.c'. needed by... Obviously ndk-build was trying to find the file under root. If I copy the file to the root '/' or if I specify the full path of 'native.c' in the make file, then things are ok.

I also tried to output $LOCAL_PATH by $(warning, '$(LOCAL_PATH)') and found no problem.

Upvotes: 2

Views: 2098

Answers (1)

Sergey K.
Sergey K.

Reputation: 25396

Create Android.mk with the following content:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := native
LOCAL_SRC_FILES := native.c
include $(BUILD_SHARED_LIBRARY)

Put native.c in the same folder where your Android.mk is.

Run ndk-build

You will have the output as follows:

D:\12314\jni>ndk-build
"Compile thumb : native <= native.c
SharedLibrary  : libnative.so
Install        : libnative.so => libs/armeabi/libnative.so

Upvotes: 1

Related Questions