Qt Android project with OpenCV - tbb compiling errors

user1282785 picture user1282785 · Sep 25, 2012 · Viewed 8.8k times · Source

I want to create a Qt Android App with OpenCV. I'm using Necessitas Qt Creator and the OpenCV 2.4.0 Android binary package on Ubuntu 12.04 (64-Bit). At the moment I just create an OpenCV Mat object.

But when I'm compiling the project I get some "undefined reference" errors for tbb functions:

> /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
...

I'm including the OpenCV libraries (also the libtbb.a) in my *.pro / qmake file:

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

Why can't OpenCV find the tbb functions? Thanks!

Answer

Andrey Kamaev picture Andrey Kamaev · Jun 26, 2013

The order of libraries is important for linking. Try to reorder lines the following way:

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