1

I'm trying to use OpenCV in a Qt Android project that I build from Qt Creator.

I use the pre-built OpenCV-2.4.10-android-sdk, and judging by their sizes, I'm linking to static libraries. Right now I'm getting linker errors, and since link-order matters in GCC, I suspect they are because my link-order is incorrect (the libs are in alphabetical order).

So what is the correct link-order, and how do I find it, considering that I'm cross-compiling on Windows?

This is from my .pro file:

LIBS += -L"c:/Workspace/OpenCV-2.4.10-android-sdk/sdk/native/libs/armeabi-v7a"\
        -L"c:/Workspace/OpenCV-2.4.10-android-sdk/sdk/native/3rdparty/libs/armeabi-v7a"
LIBS += \
    -lopencv_core\
    -lopencv_features2d\
    -lopencv_flann\
    -lopencv_highgui\
    -lopencv_imgproc\
    -lopencv_legacy\
    -lopencv_ml\
    -lopencv_objdetect\
    -lopencv_ocl\
    -lopencv_photo\
    -lopencv_stitching\
    -lopencv_superres\
    -lopencv_ts\
    -lopencv_video\
    -lopencv_videostab\
    -lIlmImf\
    -llibjasper\
    -llibjpeg\
    -llibpng\
    -llibtiff\
    -ltbb

And this is the error I'm receiving right now:

c:/Workspace/OpenCV-2.4.10-android-sdk/sdk/native/libs/armeabi-v7a/libopencv_core.a(parallel.cpp.o):parallel.cpp:function tbb::interface6::internal::start_for<tbb::blocked_range<int>, (anonymous namespace)::ProxyLoopBody, tbb::auto_partitioner const>::~start_for(): error: undefined reference to 'vtable for tbb::task'
sashoalm
  • 75,001
  • 122
  • 434
  • 781

1 Answers1

4

For anyone that might have the same problem, this is the correct order of OpenCV. I found it in c:\Workspace\OpenCV-2.4.10-android-sdk\sdk\native\jni\OpenCVModules_armeabi_v7a.cmake:

foreach(_expectedTarget libtiff libjpeg libjasper libpng IlmImf tbb opencv_core opencv_androidcamera opencv_flann opencv_imgproc opencv_highgui opencv_features2d opencv_calib3d opencv_ml opencv_objdetect opencv_video opencv_contrib opencv_photo opencv_java opencv_legacy opencv_ocl opencv_stitching opencv_superres opencv_ts opencv_videostab)

When compiled in the order given in that foreach, they worked. I couldn't find any tools that will give me the correct order, at least not for the Android NDK on Windows.

So this is how the LIBS entries should look:

LIBS += -L"c:/Workspace/OpenCV-2.4.10-android-sdk/sdk/native/libs/armeabi-v7a"\
        -L"c:/Workspace/OpenCV-2.4.10-android-sdk/sdk/native/3rdparty/libs/armeabi-v7a"
LIBS += \
    -llibtiff\
    -llibjpeg\
    -llibjasper\
    -llibpng\
    -lIlmImf\
    -ltbb\
    -lopencv_core\
    -lopencv_androidcamera\
    -lopencv_flann\
    -lopencv_imgproc\
    -lopencv_highgui\
    -lopencv_features2d\
    -lopencv_calib3d\
    -lopencv_ml\
    -lopencv_objdetect\
    -lopencv_video\
    -lopencv_contrib\
    -lopencv_photo\
    -lopencv_java\
    -lopencv_legacy\
    -lopencv_ocl\
    -lopencv_stitching\
    -lopencv_superres\
    -lopencv_ts\
    -lopencv_videostab
sashoalm
  • 75,001
  • 122
  • 434
  • 781