From this tutorial.
see i have one pre-built static library named as stackoverflow.a
and it has stackoverflow.h
now i want to use the function of that static library in
ndk_demo.c
// that tutorial has this file
for that inside ndk_demo.c
i have added
#include 'stackoverflow.h'
Edit
inside `android-ndk-r7c`
|
apps
|
ndk_demo
|
-----------------
| |
project Application.mk
|
--------------------
| |
all other |
folder jni
|
-------------------------------------------------------------------
| | | | |
ndk_demo.c stackoverflow.h lib com_marakana Android.mk
| _NativeLib.h
|
--------------------
| |
Android.mk libstackoverflow.a
Now Application.mk
APP_PROJECT_PATH := $(call my-dir)/project
APP_MODULES := ndk_demo stackover
Now jni/Android.mk
include $(call all-subdir-makefiles)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ndk_demo
LOCAL_SRC_FILES := ndk_demo.c
LOCAL_STATIC_LIBRARIES := stackover
include $(BUILD_SHARED_LIBRARY)
now jni/lib/Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := stackover
LOCAL_SRC_FILES := libstackoverflow.a
include $(PREBUILT_STATIC_LIBRARY)
LOCAL_PATH := $(call my-dir)
Now from android-ndk-r7c
directory
i run
make APP=ndk_demo
it shows me error like
Android NDK: Building for application 'ndk_demo'
make: *** No rule to make target `build/core/ndk_demo.c', needed by `out/apps/ndk_demo/armeabi/objs/ndk_demo/ndk_demo.o'. Stop.
why this happening i am not getting ?
if i comment
#include $(call all-subdir-makefiles)
this from jni/Android.mk
then it shows following error
Android NDK: Building for application 'ndk_demo'
Compile thumb : ndk_demo <= ndk_demo.c
SharedLibrary : libndk_demo.so
./out/apps/ndk_demo/armeabi/objs/ndk_demo/ndk_demo.o: In function `Java_com_marakana_NativeLib_hello':
/home/jeegar/android-ndk-r7c/apps/ndk_demo/project/jni/ndk_demo.c:10: undefined reference to `stackoverflowInit'
collect2: ld returned 1 exit status
make: *** [out/apps/ndk_demo/armeabi/libndk_demo.so] Error 1
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…