I have a simple subdir project with following file tree in Qt:
nrc.pro
gui
-gui.pro
-mainwindow.h
-mainwindow.cpp
-main.cpp
nrclib
-nrclib.pro
-nrclib.h
-nrclib.cpp
-otherfile.h
-otherfile.cpp
nrclib uses OpenCV, so I have added appropriate "includepath and libs" for both Linux and Windows to nrclib.pro
and I have used nrclib as a library for gui.pro, I have not used any opencv function in gui project, so there is no need to add opencv's includepath and libs to gui.pro, and I have #include <opencv/cv.h>
in otherfile.h and #included "otherfile.h"
in nrclib.h and #include "nrclib.h"
in mainwindow.h.
so far so good. This project worked perfect under both windows and Linux. But today I made a change, I added a function to "nrclib.h" and it needed opencv, so I did #include <opencv/cv.h>
to nrclib.h. It works perfectly under Linux. But when I wanted to compile it in Windows it gives me: "<opencv/cv.h>: no such file or directory"
.
If I delete the inclusion, everything works perfectly. and If I don't use "subdir template" in Qt, there won't be any problem.
But if I use subdir template in windows I have to add LIBS
and INCLUDEPATH
of OpenCV to gui.pro, although no opencv related function is used in gui project, I have only included nrclib.h in mainwindow.h.
My question is: why should I add LIBS
and INCLUDEPATH
of OpenCV in gui.pro? Why does it give me "no such file or directory" for an inclusion that is already being used in another header?
sorry for long and useless question, it is bugging my mind.
edit 1: I am aware of this question but there is not a good answer there, there should be no need to add "OpenCV" to gui.pro, it doesn't need it.