Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

INCLUDEPATH in qmake project file doesn't work

Tags:

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 :

#include <opencv\cv.h> 

The compiler indicates an error:

Cannot open include file: 'opencv\cv.h': No such file or directory

but if I write this in my cpp:

#include "C:\OpenCV\build\include\opencv\cv.h" 

it works!

I build the project from within Qt Creator. What am I doing wrong?

like image 285
user2794529 Avatar asked Sep 27 '13 10:09

user2794529


2 Answers

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')

like image 182
Flu2fy Unicorn Avatar answered Sep 28 '22 03:09

Flu2fy Unicorn


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.

like image 35
Kuba hasn't forgotten Monica Avatar answered Sep 28 '22 02:09

Kuba hasn't forgotten Monica