11

I'm using Qt to write an Android app, using opencv. I've set up everything so that my app runs correctly without opencv. However, after I included opencv 3.2 (by downloading the latest sdk and setting up the library paths), compilation fails with hundreds of undefined reference errors, all of them involving carotene_o4t.

C:/opencv/OpenCV-android-sdk/sdk/native/libs/armeabi-v7a/libopencv_core.a(arithm.cpp.o):arithm.cpp:function cv::hal::cmp8u(unsigned char const*, unsigned int, unsigned char const*, unsigned int, unsigned char*, unsigned int, int, int, void*): error: undefined reference to 'carotene_o4t::isSupportedConfiguration()'
C:/opencv/OpenCV-android-sdk/sdk/native/libs/armeabi-v7a/libopencv_core.a(arithm.cpp.o):arithm.cpp:function cv::hal::cmp8u(unsigned char const*, unsigned int, unsigned char const*, unsigned int, unsigned char*, unsigned int, int, int, void*): error: undefined reference to 'carotene_o4t::cmpGE(carotene_o4t::Size2D const&, unsigned char const*, int, unsigned char const*, int, unsigned char*, int)'
C:/opencv/OpenCV-android-sdk/sdk/native/libs/armeabi-v7a/libopencv_core.a(arithm.cpp.o):arithm.cpp:function cv::hal::cmp8u(unsigned char const*, unsigned int, unsigned char const*, unsigned int, unsigned char*, unsigned int, int, int, void*): error: undefined reference to 'carotene_o4t::cmpEQ(carotene_o4t::Size2D const&, unsigned char const*, int, unsigned char const*, int, unsigned char*, int)'

... and so on.

What is this carotene_o4t, and how can I resolve this problem? Searching for these messages, Google returns with zero results.

The project file looks like this:

INCLUDEPATH += C:/opencv/OpenCV-android-sdk/sdk/native/jni/include

OPENCV3RDPARTYLIBS = C:/opencv/OpenCV-android-sdk/sdk/native/3rdparty/libs/armeabi-v7a
OPENCVNATIVELIBS = C:/opencv/OpenCV-android-sdk/sdk/native/libs/armeabi-v7a

LIBS += $$OPENCV3RDPARTYLIBS/liblibtiff.a \
    $$OPENCV3RDPARTYLIBS/liblibjpeg.a \
    $$OPENCV3RDPARTYLIBS/liblibjasper.a \
    $$OPENCV3RDPARTYLIBS/liblibpng.a \
    $$OPENCV3RDPARTYLIBS/libtbb.a \
    $$OPENCV3RDPARTYLIBS/libIlmImf.a

LIBS += $$OPENCVNATIVELIBS/libopencv_core.a \
    $$OPENCVNATIVELIBS/libopencv_flann.a \
    $$OPENCVNATIVELIBS/libopencv_imgproc.a \
    $$OPENCVNATIVELIBS/libopencv_highgui.a \
    $$OPENCVNATIVELIBS/libopencv_features2d.a \
    $$OPENCVNATIVELIBS/libopencv_calib3d.a \
    $$OPENCVNATIVELIBS/libopencv_ml.a \
    $$OPENCVNATIVELIBS/libopencv_objdetect.a \
    $$OPENCVNATIVELIBS/libopencv_photo.a \
    $$OPENCVNATIVELIBS/libopencv_stitching.a \
    $$OPENCVNATIVELIBS/libopencv_superres.a \
    $$OPENCVNATIVELIBS/libopencv_video.a \
    $$OPENCVNATIVELIBS/libopencv_videostab.a \
    $$OPENCVNATIVELIBS/libopencv_java3.so \
    $$OPENCVNATIVELIBS/libopencv_calib3d.a \
    $$OPENCVNATIVELIBS/libopencv_imgcodecs.a \
    $$OPENCVNATIVELIBS/libopencv_shape.a \
    $$OPENCVNATIVELIBS/libopencv_videoio.a \



SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
    ANDROID_EXTRA_LIBS = \
        $$PWD/../../../../opencv/OpenCV-android-sdk/sdk/native/libs/armeabi-v7a/libopencv_java3.so
}

The paths themselves seem to be correct, because if I don't include opencv.hpp in my code, it runs perfectly. On the other hand, having wrong paths in the project files prevent building it.

vsz
  • 4,811
  • 7
  • 41
  • 78
  • Quote from [here](https://github.com/opencv/opencv/tree/master/3rdparty/carotene): "This is Carotene, a low-level library containing optimized CPU routines that are useful for computer vision algorithms." From this pull request: [NVIDIA Carotene - NVIDIA Hardware-Abstraction-Layer for ARM platforms](https://github.com/opencv/opencv/pull/6770) – Catree Jan 16 '17 at 15:50
  • This means that it's either a bug in the 3.2 version, or the 3.1 version didn't use it, as I have no such problems with 3.1. I guess I'll have to compile 3.2 myself instead of using the sdk. – vsz Jan 17 '17 at 06:42
  • 1
    It was introduced in OpenCV 3.2. You should be able to disable Carotene in [CMake](https://github.com/opencv/opencv/blob/3.2.0/CMakeLists.txt#L174) when you build OpenCV from source. – Catree Jan 18 '17 at 00:39
  • @vsz did you manage to compile 3.2 without carotene? if so can you provide some instructions ? thanks – Stelian Morariu Nov 05 '17 at 13:33
  • @StelianMorariu : If I remember correctly, I just unchecked it in the CMake GUI, and opencv was built correctly. – vsz Nov 05 '17 at 22:40
  • @vsz thanks, I was trying to build from command line and got some errors... – Stelian Morariu Nov 06 '17 at 10:38

1 Answers1

12

You need to link with libtegra_hal.

It is included in the 3rdparty folder: sdk/native/3rdparty/libs/armeabi/libtegra_hal.a

scx
  • 3,221
  • 1
  • 19
  • 37