gpt4 book ai didi

android-opencv cvCanny链接错误

转载 作者:太空狗 更新时间:2023-10-29 12:58:15 30 4
gpt4 key购买 nike

我正在使用 android-opencv (android-opencv -- http://code.google.com/p/android-opencv/ -- ) ,它构建成功并且运行良好。然后我尝试使用“cvCanny”来检测人脸,但链接器报告错误“undefined reference”。

我尝试了很多方法来解决这个问题,但无法解决。

/home1/apps/c/opencv-android/opencv/obj/local/armeabi-v7a/libobjdetect.a(haar.o): In function cvHaarDetectObjects':
/home1/apps/c/opencv-android/opencv/modules/objdetect/src/haar.cpp:1127:
undefined reference to
cvCanny' collect2: ld returned 1 exit status

编译命令

/home1/android-ndk-crystax/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi-gcc -nostdlib -Wl,-soname,libandroid-opencv.so -Wl,-shared,-Bsymbolic /home1/apps/c/opencv-android/opencv/android/obj/local/armeabi-v7a/objs/android-opencv/yuv420sp2rgb.o /home1/apps/c/opencv-android/opencv/android/obj/local/armeabi-v7a/objs/android-opencv/gen/android_cv_wrap.o /home1/apps/c/opencv-android/opencv/android/obj/local/armeabi-v7a/objs/android-opencv/image_pool.o /home1/apps/c/opencv-android/opencv/android/obj/local/armeabi-v7a/objs/android-opencv/gl_code.o /home1/apps/c/opencv-android/opencv/android/obj/local/armeabi-v7a/objs/android-opencv/Calibration.o /home1/apps/c/opencv-android/opencv/android/obj/local/armeabi-v7a/objs/android-opencv/Processor.o /home1/apps/c/opencv-android/opencv/android/obj/local/armeabi-v7a/objs/android-opencv/gen/cvcamera_swig.o -Wl,--whole-archive -Wl,--no-whole-archive /home1/android-ndk-crystax/build/platforms/android-5/arch-arm/usr/lib/libmissing.a /home1/android-ndk-crystax/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/lib/libstdc++.a /home1/android-ndk-crystax/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/lib/libsupc++.a /home1/android-ndk-crystax/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/libgcc.a /home1/android-ndk-crystax/build/platforms/android-5/arch-arm/usr/lib/libc.so /home1/android-ndk-crystax/build/platforms/android-5/arch-arm/usr/lib/libm.so -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -L/home1/android-ndk-crystax/build/platforms/android-5/arch-arm/usr/lib -L/home1/apps/c/opencv-android/opencv/bin/ndk/local/armeabi-v7a -L/home1/apps/c/opencv-android/opencv/obj/local/armeabi-v7a -Wl,-rpath-link=/home1/apps/c/opencv-android/opencv/obj/local/armeabi-v7a -lfeatures2d -lcalib3d -limgproc -lvideo -lhighgui -lml -llegacy -lcore -lopencv_lapack -lflann -lobjdetect -lzlib -lpng -ljpeg -ljasper -llog -lGLESv2 -Wl,-rpath-link=/home1/android-ndk-crystax/build/platforms/android-5/arch-arm/usr/lib /home1/android-ndk-crystax/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/lib/libstdc++.a /home1/android-ndk-crystax/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/lib/libsupc++.a /home1/android-ndk-crystax/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/libgcc.a -o /home1/apps/c/opencv-android/opencv/android/obj/local/armeabi-v7a/libandroid-opencv.so

当我用“nm”命令检查“libimgproc.a”时,它说它有“cvCanny”的符号,但链接器提示...

nm /home1/apps/c/opencv-android/opencv/obj/local/armeabi-v7a/libimgproc.a | grep cvCanny

00000000 r ZZ7cvCannyE19_PRETTY_FUNCTION__

00000001 T cvCanny

请给我一个关于这个喜欢问题的提示......?

最佳答案

当使用 gcc(或 g++)链接带有依赖项的静态库时,顺序很重要。

由于 objdetect 依赖于 imgproc,因此它必须是第一个:

libopencv_core.a libopencv_highgui.a libopencv_objdetect.a libopencv_imgproc.a

这是因为 GNU 链接器按照给定参数的顺序解析依赖关系,在继续之前丢弃任何未引用到该点的符号。

确定重新排序库是否可以解决您的问题的一种方法是重复所有库,以便在所有其他库列表之后(再次)向链接器提供每个库列表。如果这解决了您的链接错误,那么您遇到了静态库排序问题。

关于android-opencv cvCanny链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3854982/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com