So verknüpfen Sie eine Bibliothek in einer ndk-Anwendung
Vondieses Tutorial.
siehe, ich habe eine vorgefertigte statische Bibliothek mit dem Namenstackoverflow.a
und es hatstackoverflow.h
Jetzt möchte ich die Funktion dieser statischen Bibliothek in nutzen
ndk_demo.c
// Das Tutorial hat diese Datei
dafür drinnenndk_demo.c
Ich habe hinzugefügt
<code>#include 'stackoverflow.h' </code>
Bearbeiten
<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>
JetztApplication.mk
<code>APP_PROJECT_PATH := $(call my-dir)/project APP_MODULES := ndk_demo stackover </code>
Jetztjni / Android.mk
<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>
jetztjni / lib / Android.mk
<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>
Nun vonandroid-ndk-r7c
Verzeichnis, das ich laufe
<code>make APP=ndk_demo </code>
Es zeigt mir Fehler wie
<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>
Warum passiert das nicht?
wenn ich kommentiere
<code>#include $(call all-subdir-makefiles) </code>
das vonjni/Android.mk
dann zeigt es folgenden fehler
<code>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 </code>