11
votes

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.

1
Quote from here: "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 platformsCatree
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
It was introduced in OpenCV 3.2. You should be able to disable Carotene in CMake when you build OpenCV from source.Catree
@vsz did you manage to compile 3.2 without carotene? if so can you provide some instructions ? thanksStelian Morariu
@StelianMorariu : If I remember correctly, I just unchecked it in the CMake GUI, and opencv was built correctly.vsz

1 Answers

11
votes

You need to link with libtegra_hal.

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