Important: Please read the 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 += \
    FORMS += \
    LIBS += -L/usr/local/Cellar/opencv/4.4.0_2/lib \
         -lopencv_core \
    # 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:


    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.

  • Lack INCLUDEPATH such as:
    INCLUDEPATH += /usr/local/include

Log in to reply