Error: 'Cannot open source file "XXXXX.hpp"' but app still building and working!
So I installed OpenCV 2.4.9 on a new computer and followed the various steps to link it's dll/lib in Visual Studio 2012 C++, as provided in the doc.
Using the sample code in the doc (copy/paste), the #include "opencv2\highgui\highgui.hpp" and all others opencv related includes are underlined in red, as well as every mention of opencv function/vars in the code. The error provided is "Cannot open source file "XXXXXXX.hpp", which is strange since I followed all the steps (even replacing the version number of the libs).
Stranger is that I compile and no error, run the example program from the command line and it works correctly.
So I started a new solution and tried to build another sample program. Again, same error in the IDE and the program builds just fine.
Anyone ever had a similar problem? In the past, when this kind of error happened, I was simply unable to build the app.
Maybe the compiler is more forgiving or searching more agressive than Visual Studio. This is most likely a include path setting not (correctly) set in VS.
True, the problem was from the path. I will answer below
I will answer as soon as possible. The short answer is I used %OPENCV_DIR% (the Windows way) in my path setting of Visual Studio instead of $(OPENCV_DIR) or %(OPENCV_DIR). I assume that when Windows executed the program, it just saw %OPENCV_DIR% and knew what it meant, while Intellisense just could not understand.