Cannot link OpenCV Android inside Qt

梦想的初衷 提交于 2019-12-11 09:33:01

问题


I tried to use OpenCV with Android inside Qt, but I cannot successfully link it inside Qt, I get some undefined reference errors to the side libraries (like libjpeg, libtegra_hal etc.). I used this SO answer as a reference guide.

This is my .pro file -

INCLUDEPATH += "$$PWD/../../External-Libraries/opencv-android/sdk/native/jni/include"

android {
# 3rd party libs
LIBS += \
    -L"$$PWD/../../External-Libraries/opencv-android/sdk/native/3rdparty/libs/armeabi-v7a"\
    -llibtiff\
    -llibjpeg\
    -llibjasper\
    -llibpng\
    -llibwebp\
    -lIlmImf\
    -ltbb\
    -ltegra_hal
# opencv libs
LIBS += -L"$$PWD/../../External-Libraries/opencv-android/sdk/native/libs/armeabi-v7a"\
    -lopencv_core\
    -lopencv_highgui\
    -lopencv_java3\
    -lopencv_calib3d\
    -lopencv_imgcodecs\
    -lopencv_imgproc\
    -lopencv_flann\
    -lopencv_features2d\
    -lopencv_ml\
    -lopencv_objdetect\
    -lopencv_photo\
    -lopencv_shape\
    -lopencv_stitching\
    -lopencv_superres\
    -lopencv_video\
    -lopencv_videoio\
    -lopencv_videostab
ANDROID_PACKAGE_SOURCE_DIR=$$PWD/android
}

I'm using Qt 5.8 and OpenCV 3.2.0. The errors are in this format -

libopencv_core.a: ... error: undefined reference to (method of one of the 3rd party libs)

This is an example -

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()'

Where carotene is a function of libtegra_hal.a. Is there any way to link the opencv libs with the 3rd party libs?

Thanks.

EDIT:

I can successfully compile and run the OpenCV 3.1.0 library, but not the 3.2.0 library.


回答1:


The workaround is: either use OpenCV 3.1.0 or older or compile OpenCV 3.2.0 with CAROTENE disabled.

I can't seem to find any other solutions for now.



来源:https://stackoverflow.com/questions/42608492/cannot-link-opencv-android-inside-qt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!