INCLUDEPATH in qmake project file doesn't work

前端 未结 12 2075
梦如初夏
梦如初夏 2020-12-06 09:53

I\'ve got a problem with include in a qmake project. In my .pro file I\'ve got:

INCLUDEPATH += \"C:\\OpenCV\\build\\include\"

and in my cpp

相关标签:
12条回答
  • 2020-12-06 10:08

    here's one of my pro files:

        # Blah Application
    
    TEMPLATE  = app
    CONFIG   += qt console staticlib debug_and_release
    QT       -= gui
    QT       += network sql xml
    TARGET    = blah
    
    CONFIG(debug, debug|release){
        DESTDIR = debug
        LIBS += -L../../../lib/core/debug -lcore
    } else {
        DESTDIR = release
        LIBS += -L../../../lib/core/release -lcore
    }
    DEPENDPATH  += . ../../lib ../../../lib/core
    INCLUDEPATH += . ../../lib ../../../lib/core
    
    # Library files
    HEADERS += mtBlahRTP.h
    SOURCES += mtBlahRTP.cpp
    
    # Input
    HEADERS +=
    SOURCES += main.cpp
    

    The include path points to the RELATIVE directory of my lib files. mtBlahRTP.h and mtBlahRTP.cpp are in ../../lib

    0 讨论(0)
  • 2020-12-06 10:10

    I had to do two steps: (re-)run qmake and rebuild the whole project - only then the INCLUDEPATH setting was considered correctly. (With QtCreator 3.5 and 3.6 (Qt 5.5 and Qt 5.6) on Windows.)

    0 讨论(0)
  • 2020-12-06 10:15

    I ran into a similar issue and what I found is that the QtCreator IDE is not re-reading the results of qmake and updating the "Cannot open" message. You need to close the offending file and re-open it - then you'll see that it no longer displays the error.

    0 讨论(0)
  • 2020-12-06 10:17

    Under windows you have to eliminate the -I before each directory that is added into the INCLUDEPATH variable. For example: Under windows:

    INCLUDEPATH += "C:\lib\boost_1_61_0" (back-slash)
    

    Under linux & mac:

    INCLUDEPATH += -I"$$(HOME)/lib/boost_1_61_0" (note the -I and forward-slash)
    

    I'm not sure whether it depends on different qmake version or not. But after finishing qmake command, I check the Makefile and the double -I is the issue.

    0 讨论(0)
  • 2020-12-06 10:18

    You have to run qmake(build->run qmake) to validate changes in the pro file. Qt creator Adding external library (still: Cannot open include file: 'GL/glew.h')

    0 讨论(0)
  • 2020-12-06 10:24

    I have the same question, before building or running, you should qmake(Build=>qmake) it.

    My configurations for INCLUDEPATH:

    INCLUDEPATH+=D:\opencv\opencv\build\include
    INCLUDEPATH+=D:\opencv\opencv\build\include\opencv
    INCLUDEPATH+=D:\opencv\opencv\build\include\opencv2
    
    0 讨论(0)
提交回复
热议问题