INCLUDEPATH in qmake project file doesn't work

前端 未结 12 2076
梦如初夏
梦如初夏 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:24

    Somehow it did not work for when I had several INCLUDEPATH +=. When I combined the stuff into a single on it suddenly worked.

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

    You need to do several things. Fist, in the .pro file, you need quotation marks two backslashes at a time, like this:

    INCLUDEPATH += "C:\\OpenCV\\build\\include\\opencv\\cv.h"
    

    You alse need a frontslash in the #include in your .cpp file like this:

    #include <opencv/cv.h>
    

    When you've done this, delete the build folder. This is the folder with a very complicated name of the type build-untitled-Desktop_Qt_5_7_0_MSVC2015_32bit-Release. Then, in the Build menu, press "Run qmake". When you've done all this, it should compile fine.

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

    The only problem you are making is incorrectly linking the OpenCV library. The other answers given here may or may not work, but I have posted on another thread a surefire way to solve this problem using the "Add Library" wizard inside Qt Creator: https://stackoverflow.com/a/51914928/10245006

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

    You should use double backslashes when in windows for qt creator with msvc. like this: INCLUDEPATH += C:\\libcurl\\libcurl-vc-x64-release-dll-ipv6-sspi-winssl\\include

    this will fix the problem.

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

    Your problem may be related to the fact that having backslashes in naked #include directives is undefined behavior.

    Do the following.

    1. Replace your include with

      #include <opencv/cv.h>
      

      Note the forward slash!

    2. Remove the shadow build directory that Qt Creator has made for you. You will find it above the project directory, its name begins with build-.

    3. Rebuild the project.

    Note that this takes care of rerunning qmake.

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

    I was getting the error:

    canserialcomm.o: In function `CanSerialComm::CanSerialComm()':
    canserialcomm.cpp:(.text+0xc1): undefined reference to `vtable for CanSerialComm'
    

    It turns out that the cause was it wasn't able to find canserialcomm.h where that constructor is declared. This was despite me having INCLUDEPATH in the project file point to the directory containing that header file:

    INCLUDEPATH += . \
            ..
    

    What I had to do to fix this is explicitely specify the header file; I added:

    HEADER += ../canserialcomm.h
    
    0 讨论(0)
提交回复
热议问题