我想用OpenCV创建一个Qt Android应用程序。我在Ubuntu 12.04(64位)上使用Necessitas Qt Creator和OpenCV 2.4.0 Android二进制包。目前我只是创建一个OpenCV Mat对象。
但是当我编译项目时,我得到一些tbb函数的“未定义引用”错误:
> /home/kolbe/src/android-sdk-linux/OpenCV-2.4.0/libs/armeabi-v7a/libopencv_core.a(stat.cpp.o):-1: In function tbb::interface6::internal::start_for<tbb::blocked_range<int>, cv::BatchDistInvoker, tbb::auto_partitioner>::execute():
stat.cpp:-1: error: undefined reference to tbb::internal::allocate_continuation_proxy::allocate(unsigned int) const
stat.cpp:-1: error: undefined reference to tbb::internal::allocate_continuation_proxy::allocate(unsigned int) const
...
我在我的* .pro / qmake文件中包含了OpenCV库(也就是libtbb.a):
ANDROID_OPENCV = /home/kolbe/src/android-sdk-linux/OpenCV-2.4.0
LIBS += \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_calib3d.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_flann.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_objdetect.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_contrib.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_video.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_ml.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_legacy.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_highgui.a \
$$ANDROID_OPENCV/share/OpenCV/3rdparty/libs/armeabi-v7a/liblibjpeg.a \
$$ANDROID_OPENCV/share/OpenCV/3rdparty/libs/armeabi-v7a/liblibpng.a \
$$ANDROID_OPENCV/share/OpenCV/3rdparty/libs/armeabi-v7a/liblibtiff.a \
$$ANDROID_OPENCV/share/OpenCV/3rdparty/libs/armeabi-v7a/liblibjasper.a \
$$ANDROID_OPENCV/share/OpenCV/3rdparty/libs/armeabi-v7a/libtbb.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_ts.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_imgproc.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_core.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_androidcamera.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_features2d.a
INCLUDEPATH += $$ANDROID_OPENCV/include/opencv/
INCLUDEPATH += $$ANDROID_OPENCV/include/opencv2/
INCLUDEPATH += $$ANDROID_OPENCV/include/
CONFIG+=link_pkgconfig PKGCONFIG+=opencv
为什么OpenCV找不到tbb功能?谢谢!
答案 0 :(得分:2)
库的顺序对于链接很重要。尝试按以下方式重新排序行:
LIBS += \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_contrib.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_legacy.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_ml.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_objdetect.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_calib3d.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_video.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_features2d.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_highgui.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_androidcamera.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_flann.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_imgproc.a \
$$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_core.a \
$$ANDROID_OPENCV/share/OpenCV/3rdparty/libs/armeabi-v7a/liblibjpeg.a \
$$ANDROID_OPENCV/share/OpenCV/3rdparty/libs/armeabi-v7a/liblibpng.a \
$$ANDROID_OPENCV/share/OpenCV/3rdparty/libs/armeabi-v7a/liblibtiff.a \
$$ANDROID_OPENCV/share/OpenCV/3rdparty/libs/armeabi-v7a/liblibjasper.a \
$$ANDROID_OPENCV/share/OpenCV/3rdparty/libs/armeabi-v7a/libtbb.a
答案 1 :(得分:0)
您可以尝试以下方法......它对我有用
将libopencv_java.so复制到QT_INSTALLDIR / 5.1.1 / android_armv7 / lib 然后在.pro中添加以下内容 LIBS + = -lopencv_java