Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to link any library in ndk application
    text
    copied!<p>From <a href="http://marakana.com/forums/android/examples/49.html" rel="nofollow">this tutorial</a>.</p> <p>see i have one pre-built static library named as <code>stackoverflow.a</code> and it has <code>stackoverflow.h</code> </p> <p>now i want to use the function of that static library in </p> <p><code>ndk_demo.c</code> // that tutorial has this file </p> <p>for that inside <code>ndk_demo.c</code> i have added</p> <pre><code>#include 'stackoverflow.h' </code></pre> <hr> <p><strong>Edit</strong></p> <pre><code>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 </code></pre> <p>Now <strong>Application.mk</strong></p> <pre><code>APP_PROJECT_PATH := $(call my-dir)/project APP_MODULES := ndk_demo stackover </code></pre> <p>Now <strong>jni/Android.mk</strong></p> <pre><code>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) </code></pre> <p>now <strong>jni/lib/Android.mk</strong></p> <pre><code> 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) </code></pre> <p>Now from <code>android-ndk-r7c</code> directory i run </p> <pre><code>make APP=ndk_demo </code></pre> <p>it shows me error like </p> <pre><code>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. </code></pre> <p>why this happening i am not getting ?</p> <p>if i comment </p> <pre><code>#include $(call all-subdir-makefiles) </code></pre> <p>this from <code>jni/Android.mk</code> then it shows following error</p> <pre><code>Android NDK: Building for application 'ndk_demo' Compile thumb : ndk_demo &lt;= 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 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload