使用我的模块构建opencv .a和.so for android的问题

时间:2012-05-30 08:54:41

标签: android opencv

我是OpenCV的新手,也是这个群体的新手。目前我正在开发一些需要OpenCV libs的Android手机ICS项目。 我的模块代码是用C编写的,在那段代码中我想调用一些OpenCV lib函数。 刚开始,我已经下载了适用于Android平台的OpenCV-2.4.0。

  • 到目前为止我采取的步骤:

    1. 将.a和.so文件复制到我的模块文件夹中\ OpenCV-2.4.0-android-bin.tar \ OpenCV-2.4.0-android-bin \ OpenCV-2.4.0 \ libs \ armeabi-v7a
    2. 将.h文件复制到我的模块文件夹中\ OpenCV-2.4.0-android-bin.tar \ OpenCV-2.4.0-android-bin \ OpenCV-2.4.0 \ include
    3. 在我的模块的android.mk文件中添加.h,.a和.so路径。
    4. 执行构建。

现在我收到了libopencv_core.a中的链接错误 当我从.mk文件中删除libopencv_core.a时,构建成功。 我认为libopencv_core.a依赖于其他lib来实现这些功能(gzopen,gzclose等)

prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: out/target/product/jaguark/obj/STATIC_LIBRARIES/libopencv_core_intermediates/libopencv_core.a(persistence.cpp.o): in function icvPuts(CvFileStorage*, char const*):persistence.cpp(.text._ZL7icvPutsP13CvFileStoragePKc+0x20): error: undefined reference to 'gzputs'
prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: out/target/product/jaguark/obj/STATIC_LIBRARIES/libopencv_core_intermediates/libopencv_core.a(persistence.cpp.o): in function icvGets(CvFileStorage*, char*, int):persistence.cpp(.text._ZL7icvGetsP13CvFileStoragePci+0x26): error: undefined reference to 'gzgets'
prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: out/target/product/jaguark/obj/STATIC_LIBRARIES/libopencv_core_intermediates/libopencv_core.a(persistence.cpp.o): in function icvXMLSkipSpaces(CvFileStorage*, char*, int):persistence.cpp(.text._ZL16icvXMLSkipSpacesP13CvFileStoragePci+0x1e2): error: undefined reference to 'gzgets'
prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: out/target/product/jaguark/obj/STATIC_LIBRARIES/libopencv_core_intermediates/libopencv_core.a(persistence.cpp.o): in function icvXMLSkipSpaces(CvFileStorage*, char*, int):persistence.cpp(.text._ZL16icvXMLSkipSpacesP13CvFileStoragePci+0x208): error: undefined reference to 'gzeof'
prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: out/target/product/jaguark/obj/STATIC_LIBRARIES/libopencv_core_intermediates/libopencv_core.a(persistence.cpp.o): in function icvXMLSkipSpaces(CvFileStorage*, char*, int):persistence.cpp(.text._ZL16icvXMLSkipSpacesP13CvFileStoragePci+0x33c): error: undefined reference to 'gzeof'

1 个答案:

答案 0 :(得分:3)

您可以按照以下tutorials关于如何将OpenCV用于Android项目和NDK-build。在开始时它有点棘手。我也遇到过一个库的问题,每次编译后都会消失,而且我每次都要反复包含。