我需要在android ndk中使用minizip和zlib。
我的jni / MyApp / Android.mk文件:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := MyApp
LOCAL_SRC_FILES := MyApp.cpp
LOCAL_LDLIBS := -lz
include $(BUILD_SHARED_LIBRARY)
我的jni / Android.mk
LOCAL_PATH := $(call my-dir)
include $(call all-subdir-makefiles)
我的jni / MyApp / MyApp.cpp
#include <zlib.h>
#include "minizip/unzip.h" #it's in jni/MyApp/minizip/unzip.h
void unzip(char* file, char* folder) {
unzFile zip = unzOpen(file);
}
我的jni / Application.mk
APP_MODULES := MyApp
APP_STL := gnustl_static
但是,当我编译它时:
Gdbserver : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
SharedLibrary : libMyApp.so
C:/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:
Z:/workspace/MyApp/obj/local/armeabi/objs-debug/MyApp/MyApp.o: in function unzip(char*, char*):Z:/workspace/MyApp/jni/MyApp/MyApp.cpp:5: error: undefined reference to 'unzOpen' collect2: ld returned 1 exit status make: *** [Z:/workspace/MyApp/obj/local/armeabi/libMyApp.so] Error 1
如果我删除行“unzFile zip = unzOpen(file);”它的工作原理
你能帮帮我吗? :d谢谢!
答案 0 :(得分:3)
...喔
我忘了在LOCAL_SRC_FILES:D
中添加c文件