【问题标题】:OpenCV2.4 with Android Native ActivityOpenCV2.4 与 Android Native Activity
【发布时间】:2012-06-07 03:41:28
【问题描述】:

我目前面临与in this question 相同的问题,只是我使用的是 2.4 版本而不是 2.3.1。

我已将本机活动(从 ndk 示例)转换为 c++ 并修改了 android.mk 和 application.mk。

我也有同样的错误(有 ~Mat 等等)。

当我阅读问题的答案时,我意识到我需要添加 OPENCV_INSTALL_MODULES:=on and OPENCV_LIB_TYPE:=STATIC(这很奇怪,因为我有一个本地 openCV 的另一个项目不需要这两行)。

但是还是不行。

Android.mk 如下:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

OPENCV_LIB_TYPE:=STATIC
OPENCV_INSTALL_MODULES:=on

include includeOpenCV.mk

ifeq ("$(wildcard $(OPENCV_MK_PATH))","")
    #try to load OpenCV.mk from default install location
    include $(TOOLCHAIN_PREBUILT_ROOT)/user/share/OpenCV/OpenCV.mk
else
    include $(OPENCV_MK_PATH)
endif

LOCAL_MODULE    := native-activity
LOCAL_SRC_FILES := main.cpp engine.cpp
LOCAL_LDLIBS    := -llog -landroid -lEGL -lGLESv1_CM
LOCAL_STATIC_LIBRARIES += android_native_app_glue


include $(BUILD_SHARED_LIBRARY)

$(call import-module,android/native_app_glue)

我收到以下错误:

./obj/local/armeabi-v7a/libopencv_core.a(persistence.cpp.o): In function `icvPuts(CvFileStorage*, char const*)':
persistence.cpp:(.text._ZL7icvPutsP13CvFileStoragePKc+0x20): undefined reference to `gzputs'
./obj/local/armeabi-v7a/libopencv_core.a(persistence.cpp.o): In function `icvGets(CvFileStorage*, char*, int)':
persistence.cpp:(.text._ZL7icvGetsP13CvFileStoragePci+0x26): undefined reference to `gzgets'
./obj/local/armeabi-v7a/libopencv_core.a(persistence.cpp.o): In function `icvXMLSkipSpaces(CvFileStorage*, char*, int)':
persistence.cpp:(.text._ZL16icvXMLSkipSpacesP13CvFileStoragePci+0x1e2): undefined reference to `gzgets'
persistence.cpp:(.text._ZL16icvXMLSkipSpacesP13CvFileStoragePci+0x208): undefined reference to `gzeof'
persistence.cpp:(.text._ZL16icvXMLSkipSpacesP13CvFileStoragePci+0x33c): undefined reference to `gzeof'
./obj/local/armeabi-v7a/libopencv_core.a(persistence.cpp.o): In function `_ZL16icvYMLSkipSpacesP13CvFileStoragePcii.clone.3':
persistence.cpp:(.text._ZL16icvYMLSkipSpacesP13CvFileStoragePcii.clone.3+0x124): undefined reference to `gzgets'
persistence.cpp:(.text._ZL16icvYMLSkipSpacesP13CvFileStoragePcii.clone.3+0x170): undefined reference to `gzeof'
/cygdrive/d/soft/NVPACK/android-ndk-r7c/build/core/build-binary.mk:366: recipe for target `obj/local/armeabi-v7a/libnative-activity.so' failed
persistence.cpp:(.text._ZL16icvYMLSkipSpacesP13CvFileStoragePcii.clone.3+0x28e): undefined reference to `gzeof'
./obj/local/armeabi-v7a/libopencv_core.a(persistence.cpp.o): In function `cvReleaseFileStorage':
persistence.cpp:(.text.cvReleaseFileStorage+0x24): undefined reference to `gzclose'
./obj/local/armeabi-v7a/libopencv_core.a(persistence.cpp.o): In function `cvOpenFileStorage':
persistence.cpp:(.text.cvOpenFileStorage+0x66e): undefined reference to `gzopen'
persistence.cpp:(.text.cvOpenFileStorage+0x8fc): undefined reference to `gzclose'
persistence.cpp:(.text.cvOpenFileStorage+0xaea): undefined reference to `gzrewind'
persistence.cpp:(.text.cvOpenFileStorage+0xbee): undefined reference to `gzrewind'
persistence.cpp:(.text.cvOpenFileStorage+0xc0a): undefined reference to `gzclose'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi-v7a/libnative-activity.so] Error 1

有什么我错过的吗?

【问题讨论】:

    标签: android opencv native-activity


    【解决方案1】:

    虽然这是一个老问题,但我遇到了同样的问题并通过添加解决了它

    LOCAL_LDLIBS    += -lz # Compression library
    

    到我的 Android.mk

    【讨论】:

      【解决方案2】:

      尝试替换

      LOCAL_LDLIBS    := -llog -landroid -lEGL -lGLESv1_CM
      

      LOCAL_LDLIBS    += -llog -landroid -lEGL -lGLESv1_CM
      

      【讨论】:

      • 通过这个更正,我不再有以前的错误,但我有: 由于无效的 APK 文件,安装失败!请检查 logcat 输出以获取更多详细信息。发射取消!在日志中:pastebin.com/Brj3n1BB
      • 我结束了原生等离子项目的尝试(其中显示是通过写入位图来完成的)并且效果很好......
      【解决方案3】:

      我结束了本地等离子项目的尝试(其中显示是通过写入位图来完成的)并且效果很好。

      也许 GLES 搞砸了 OpenCV。 我认为这两个项目之间没有任何其他区别。

      问题在某种程度上得到了解决。不过,如果有人遇到同样的问题并解决了它,我很想了解导致它的原因以及如何解决它。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-02-13
        • 2018-11-07
        • 2011-11-12
        • 2012-10-12
        • 2012-04-28
        • 2020-02-16
        相关资源
        最近更新 更多