android makefile中的OpenCV/NDK - zlib编译问题



我一直在尝试编译包含OpenCV库的共享库。我的示例android make文件如下:

LOCAL_PATH := (call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libopencvXXX
LOCAL_SRC_FILES := libs/opencv/libopencvXXX.a
include $(PREBUILT_STATIC_LIBRARY)
OPENCV_LIB_TYPE := STATIC
OPENCV_INSTALL_MODULES := on
OPENCV_CAMERA_MODULES := on
LOCAL_MODULE := libXXX
LOCAL_CPPFLAGS := -std=c++11 -fexceptions
LOCAL_CPP_FEATURES += exceptions
LOCAL_CFLAGS := -std=gnu++11 -fexceptions
LOCAL_LDLIBS := -llog -ldl
LOCAL_SRC_FILES := XXX.cpp
LOCAL_C_INCLUDES := <path to opencv header files>
LOCAL_STATIC_LIBRARIES := stdc++
LOCAL_STATIC_LIBRARIES += libopencvXXX
include $(BUILD_SHARED_LIBRARY)

但是,它一直抛出以下错误:

[INFO] jni/libs/opencv/libopencv_core.a(persistence.cpp.o):persistence.cpp:function icvGets(CvFileStorage*, char*, int): error: undefined reference to 'gzgets'
[INFO] jni/libs/opencv/libopencv_core.a(persistence.cpp.o):persistence.cpp:function icvXMLSkipSpaces(CvFileStorage*, char*, int): error: undefined reference to 'gzeof'

我尝试了以下几个选项:

LOCAL_LDLIBS += -lz
LOCAL_LDLIBS += -L<NDK root>/platforms/android-19/arch-arm/usr/lib -lz

但是没有任何帮助。有人知道我该怎么解决这个问题吗?

编辑:忘记添加,当我添加以上两个选项包括'-lz'时,它会抛出一个错误,说"没有找到本机编译库,本机编译成功完成了吗?"

我发现了这个问题。我应该加上

包括$ (CLEAR_VARS)

在包含所有静态库之后。以下是修改后的Android.mk

LOCAL_PATH := (call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libopencvXXX
LOCAL_SRC_FILES := libs/opencv/libopencvXXX.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
OPENCV_LIB_TYPE := STATIC
OPENCV_INSTALL_MODULES := on
OPENCV_CAMERA_MODULES := on
LOCAL_MODULE := libXXX
LOCAL_CPPFLAGS := -std=c++11 -fexceptions
LOCAL_CPP_FEATURES += exceptions
LOCAL_CFLAGS := -std=gnu++11 -fexceptions
LOCAL_LDLIBS := -llog -ldl
LOCAL_SRC_FILES := XXX.cpp
LOCAL_C_INCLUDES := <path to opencv header files>
LOCAL_STATIC_LIBRARIES := stdc++
LOCAL_STATIC_LIBRARIES += libopencvXXX
include $(BUILD_SHARED_LIBRARY)

相关内容

  • 没有找到相关文章

最新更新