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

'opencv2/opencv.hpp' file not found



  • Dear all,
    I want to use openCV with Qt but I get this error:

    'opencv2/opencv.hpp' file not found
     'opencv2/highgui.hpp' file not found
     'opencv2/core.hpp' file not found
    

    so Qt does not know where these files are located. I added them manually.

    Finally my .pro file is:

    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    CONFIG += c++11
    
    SOURCES += \
        main.cpp \
    
    HEADERS += \
        main.h
    
    FORMS += \
        main.ui
    
    LIBS += -L/usr/local/Cellar/opencv/4.4.0_2/lib \
         -lopencv_core \
         -lopencv_highgui
    
    INCLUDEPATH += \
             /usr/local/include
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    

    I know this is one of the most encountered problem for users new to Qt. I searched well the problem but nothing solved it. I am sure the path of libraries is correct because I have already used openCV libs in Xcode.

    openCV is the latest version: 4.4.0. Is the latest version not appropriate for Qt? What do you think? I reinstalled it but nothing changes. And it is not an easy task to remove openCV and degrade its version i think.

    Any suggestion?

    Thank you for your time and attention.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Where exactly are those file located on your machine ?



  • They are located in:

    /usr/local/Cellar/opencv/4.4.0_2/lib
    

    as I write them in 'LIBS' in my .pro file.


  • Lifetime Qt Champion

    I meant the header files since those are the ones currently not found.