Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. 'opencv2/opencv.hpp' file not found
QtWS25 Last Chance

'opencv2/opencv.hpp' file not found

Scheduled Pinned Locked Moved Unsolved General and Desktop
opencvc++opencv cpp
5 Posts 3 Posters 6.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    blackbox
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Where exactly are those file located on your machine ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • B Offline
        B Offline
        blackbox
        wrote on last edited by
        #3

        They are located in:

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

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

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • S Offline
            S Offline
            SilentWolf
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved