Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

OpenCV for Android with QTCreator



  • Hi, i am using QtCreator for build a simple app for android using OpenCV. The code compile succesfully only when there aren't OpenCV object. When i add a simple cv::Mat it fails with a lot of error of type "the vtable symbol may be undefined because the class is missing its key function" this is my .pro file:

    QT       += core gui svg multimediawidgets androidextras
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = QR_test
    TEMPLATE = app
    
    # The following define makes your compiler emit warnings if you use
    # any feature of Qt which has been marked as deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if you use deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    CONFIG += c++11
    
    SOURCES += \
            main.cpp \
            mainwindow.cpp
    
    HEADERS += \
            mainwindow.h
    
    FORMS += \
            mainwindow.ui
    
    CONFIG += mobility
    MOBILITY = 
    
    linux:!android {
        # using pkg-config
        CONFIG += link_pkgconfig
        PKGCONFIG += opencv
    }
    INCLUDEPATH += /home/aromano/Work/OpenCV-android-sdk/sdk/native/jni/include/
    
    android {
        LIBS += \
                -L"/home/aromano/Work/OpenCV-android-sdk/sdk/native/3rdparty/libs/armeabi-v7a/" \
                -L"/home/aromano/Work/OpenCV-android-sdk/sdk/native/libs/armeabi-v7a/" \
                -L"/home/aromano/Work/OpenCV-android-sdk/sdk/native/staticlibs/armeabi-v7a/" \
                -lcpufeatures \
                -lIlmImf \
                -llibjasper \
                -llibjpeg-turbo \
                -llibpng \
                -llibprotobuf \
                -llibwebp \
                -ltbb \
                -ltegra_hal \
                -lopencv_calib3d \
                -lopencv_core \
                -lopencv_dnn \
                -lopencv_features2d \
                -lopencv_flann \
                -lopencv_highgui \
                -lopencv_imgcodecs \
                -lopencv_imgproc \
                -lopencv_ml \
                -lopencv_objdetect \
                -lopencv_photo \
                -lopencv_shape \
                -lopencv_stitching \
                -lopencv_superres \
                -lopencv_video \
                -lopencv_videoio \
                -lopencv_videostab
    
        ANDROID_PACKAGE_SOURCE_DIR=$$_PRO_FILE_PWD_/android
    }
    
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    

    Thanks in advice for the reply.


  • Qt Champions 2019

    @aromano Can you post the build log?



  • @jsulm I have solved the issue. The problem was

    -lopencv_core 
    

    line. I have removed it and now it builds without errors.


Log in to reply