在android ndk中链接静态库

我试图从http://developer.nvidia.com/tegra-resources ,在android ndk示例,libs文件夹中编译nvfile库。 无论如何,因为我并不需要整套图书馆,所以我拿出了我需要的图书馆,看起来是依赖关系。 这是用于编译它们的Android.mk文件。

include $(CLEAR_VARS) LOCAL_MODULE := nvthread LOCAL_CFLAGS := -Wall -g LOCAL_LDFLAGS := -Wl,-Map,xxx.map LOCAL_SRC_FILES := nv/nv_thread/nv_thread.c LOCAL_C_INCLUDES := nv include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := nvfile LOCAL_CFLAGS := -Wall -g LOCAL_LDFLAGS := -Wl,-Map,xxx.map LOCAL_SRC_FILES := nv/nv_file/nv_file.c LOCAL_C_INCLUDES := nv LOCAL_STATIC_LIBRARIES := nvthread nvapkfile include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := nvapkfile LOCAL_CFLAGS := -Wall -g LOCAL_LDFLAGS := -Wl,-Map,xxx.map LOCAL_SRC_FILES := nv/nv_apk_file/nv_apk_file.c LOCAL_C_INCLUDES := nv LOCAL_STATIC_LIBRARIES := nvthread include $(BUILD_STATIC_LIBRARY) 

nvapkfile库似乎能够很好地链接到nvthread,但是nvfile库似乎并不想链接到nvapkfile库。 源代码中的包含文件正常工作,只是每当我尝试编译它,我得到一个未定义的引用。 这是一个输出示例:

 /home/leif/MarbleMachine/android/obj/local/armeabi/libnvfile.a(nv_file.o): In function `NvFInit': /home/leif/MarbleMachine/android/jni/nv/nv_file/nv_file.c:49: undefined reference to `NvAPKInit' /home/leif/MarbleMachine/android/obj/local/armeabi/libnvfile.a(nv_file.o): In function `NvFOpen': /home/leif/MarbleMachine/android/jni/nv/nv_file/nv_file.c:77: undefined reference to `NvAPKOpen' /home/leif/MarbleMachine/android/jni/nv/nv_file/nv_file.c:82: undefined reference to `NvAPKOpen' /home/leif/MarbleMachine/android/obj/local/armeabi/libnvfile.a(nv_file.o): In function `NvFClose': /home/leif/MarbleMachine/android/jni/nv/nv_file/nv_file.c:97: undefined reference to `NvAPKClose' /home/leif/MarbleMachine/android/obj/local/armeabi/libnvfile.a(nv_file.o): In function `NvFGetc': /home/leif/MarbleMachine/android/jni/nv/nv_file/nv_file.c:118: undefined reference to `NvAPKGetc' /home/leif/MarbleMachine/android/obj/local/armeabi/libnvfile.a(nv_file.o): In function `NvFGets': /home/leif/MarbleMachine/android/jni/nv/nv_file/nv_file.c:133: undefined reference to `NvAPKGets' /home/leif/MarbleMachine/android/obj/local/armeabi/libnvfile.a(nv_file.o): In function `NvFSize': /home/leif/MarbleMachine/android/jni/nv/nv_file/nv_file.c:148: undefined reference to `NvAPKSize' /home/leif/MarbleMachine/android/obj/local/armeabi/libnvfile.a(nv_file.o): In function `NvFSeek': /home/leif/MarbleMachine/android/jni/nv/nv_file/nv_file.c:171: undefined reference to `NvAPKSeek' /home/leif/MarbleMachine/android/obj/local/armeabi/libnvfile.a(nv_file.o): In function `NvFTell': /home/leif/MarbleMachine/android/jni/nv/nv_file/nv_file.c:186: undefined reference to `NvAPKTell' /home/leif/MarbleMachine/android/obj/local/armeabi/libnvfile.a(nv_file.o): In function `NvFRead': /home/leif/MarbleMachine/android/jni/nv/nv_file/nv_file.c:201: undefined reference to `NvAPKRead' /home/leif/MarbleMachine/android/obj/local/armeabi/libnvfile.a(nv_file.o): In function `NvFEOF': /home/leif/MarbleMachine/android/jni/nv/nv_file/nv_file.c:216: undefined reference to `NvAPKEOF' 

我根本没有修改实际的c或h文件。 但是作为参考,这里是一个相关的C文件的问题:

 #include "nv_file.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #ifdef ANDROID #include "../nv_apk_file/nv_apk_file.h" #define SUPPORT_APK 1 #include <unistd.h> #endif //... void NvFInit() { #ifdef SUPPORT_APK NvAPKInit(); #endif } 

这是nv_file.c的第22-32行和第46-51行

正如你所看到的,标题正在被包括在内,但是并没有链接。 有没有人有任何想法我在这里失踪? 谢谢。

Ugg ..似乎我只是在错误的顺序。 转动这一行(在nvfile模块中):

 LOCAL_STATIC_LIBRARIES := nvthread nvapkfile 

 LOCAL_STATIC_LIBRARIES := nvapkfile nvthread 

使它编译得很好。 任何人都可以确认在LOCAL_STATIC_LIBRARIES中列出库的顺序可能很重要吗? 谢谢。