我是Android JNI的新手,我需要在我的项目中使用静态库(librwl.a)。但我现在有错误消息未定义的引用。任何人都可以请问建议的问题是什么?提前致谢
Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := staticlibrwl
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_SRC_FILES := prebuild/librwl.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := jrwl
LOCAL_SRC_FILES := rwl.cpp
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_WHOLE_STATIC_LIBRARIES := staticlibrwl
include $(BUILD_SHARED_LIBRARY)
rwl.cpp
#include <jni.h>
#include "include/librwl.h"
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jint JNICALL Java_ms_android_pos_NativeRWL_Format
(JNIEnv * env, jobject obj){
return Format();
}
JNIEXPORT jint JNICALL Java_ms_android_pos_NativeRWL_InitActionList
(JNIEnv * env, jobject obj){
return InitActionList();
}
#ifdef __cplusplus
}
#endif
部首:
#ifdef __cplusplus
extern "C" {
#endif
extern int Format();
extern int InitActionList();
#ifdef __cplusplus
}
#endif
错误讯息:
D:\Project\android-ndk-r10\ndk-build.cmd all
Android NDK: WARNING: APP_PLATFORM android-17 is larger than android:minSdkVersion 10 in ./AndroidManifest.xml
[armeabi] Gdbserver : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
[armeabi] Gdbsetup : libs/armeabi/gdb.setup
[armeabi] Compile++ thumb: jrwl <= rwl.cpp
[armeabi] SharedLibrary : libjrwl.so
D:/Project/android-ndk-r10/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs-debug/jrwl/rwl.o: in function Java_ms_android_pos_NativeRWL_Format:jni/rwl.cpp:12: error: undefined reference to 'Format'
D:/Project/android-ndk-r10/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs-debug/jrwl/rwl.o: in function Java_ms_android_pos_NativeRWL_InitActionList:jni/rwl.cpp:18: error: undefined reference to 'InitActionList'
collect2: ld returned 1 exit status
make.exe: *** [obj/local/armeabi/libjrwl.so] Error 1
使用ndk-build V = 1 -B后出现错误消息(2014年8月6日编辑):
D:\Project\android-ndk-r10\ndk-build.cmd V=1 -B all
Android NDK: WARNING: APP_PLATFORM android-17 is larger than android:minSdkVersion 10 in ./AndroidManifest.xml
del /f/q .\libs\armeabi\gdbserver >NUL 2>NUL
del /f/q .\libs\armeabi\gdb.setup >NUL 2>NUL
[armeabi] Gdbserver : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
copy /b/y "D:\Project\android-ndk-r10\prebuilt\android-arm\gdbserver\gdbserver" ".\libs\armeabi\gdbserver" > NUL
[armeabi] Gdbsetup : libs/armeabi/gdb.setup
D:/Project/android-ndk-r10/prebuilt/windows-x86_64/bin/echo.exe "set solib-search-path ./obj/local/armeabi" > ./libs/armeabi/gdb.setup
D:/Project/android-ndk-r10/prebuilt/windows-x86_64/bin/echo.exe "directory D:/Project/android-ndk-r10/platforms/android-17/arch-arm/usr/include jni/include D:/Project/android-ndk-r10/sources/cxx-stl/system/include" >> ./libs/armeabi/gdb.setup
[armeabi] Compile++ thumb: jrwl <= rwl.cpp
D:/Project/android-ndk-r10/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ -MMD -MP -MF ./obj/local/armeabi/objs-debug/jrwl/rwl.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -fno-rtti -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -O0 -UNDEBUG -marm -fno-omit-frame-pointer -Ijni/include -ID:/Project/android-ndk-r10/sources/cxx-stl/system/include -Ijni/include -Ijni -DANDROID -Wa,--noexecstack -Wformat -Werror=format-security -ID:/Project/android-ndk-r10/platforms/android-17/arch-arm/usr/include -c jni/rwl.cpp -o ./obj/local/armeabi/objs-debug/jrwl/rwl.o
[armeabi] StaticLibrary : libstdc++.a
del /f/q obj\local\armeabi\libstdc++.a >NUL 2>NUL
D:/Project/android-ndk-r10/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/arm-linux-androideabi-ar crsD ./obj/local/armeabi/libstdc++.a
[armeabi] SharedLibrary : libjrwl.so
D:/Project/android-ndk-r10/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ -Wl,-soname,libjrwl.so -shared --sysroot=D:/Project/android-ndk-r10/platforms/android-17/arch-arm ./obj/local/armeabi/objs-debug/jrwl/rwl.o -Wl,--whole-archive jni/prebuild/librwl.a -Wl,--no-whole-archive ./obj/local/armeabi/libstdc++.a -lgcc -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -LD:/Project/android-ndk-r10/platforms/android-17/arch-arm/usr/lib -L./prebuild -lstdc++ -lc -lm -o ./obj/local/armeabi/libjrwl.so
D:/Project/android-ndk-r10/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs-debug/jrwl/rwl.o: in function Java_ms_android_pos_NativeRWL_Format:jni/rwl.cpp:12: error: undefined reference to 'Format'
D:/Project/android-ndk-r10/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs-debug/jrwl/rwl.o: in function Java_ms_android_pos_NativeRWL_InitActionList:jni/rwl.cpp:18: error: undefined reference to 'InitActionList'
collect2: ld returned 1 exit status
make.exe: *** [obj/local/armeabi/libjrwl.so] Error 1