Casper_2211
Casper_2211

Reputation: 1091

Header file cannot be found in my C++ project

I just downloaded some files (TinyXML.h) and added the files next to my other header and cpp files. I also added the line to my main cpp file

#include "tinyxml.h"

however I still get the error

fatal error C1083: Cannot open include file: 'tinyxml.h': No such file or directory

Now if I add the exact path of the file in the properties of my project ("add additional include directories") then I do not get this error. I wanted to know how I could resolve this issue. Since VS2010 has no issue finding my other header files that are placed right next to it why is it having a problem with this one ?

Upvotes: 0

Views: 2105

Answers (1)

Luchian Grigore
Luchian Grigore

Reputation: 258548

First off, I wouldn't just copy the 3rd party headers over to your project directory. Just keep them in their own own folder and add that folder to the additional include directories.

Second, if the header is in the same place as the source file, the include should work as-is. So I don't think that's it (assuming you got the capitalization right). I think you're actually looking at a different source file than the one you have in that directory. (you can tell this is the case by hovering over the file's tab in Visual Studio and checking the path or opening the source file you think you included the file in). I'm 99% sure you're compiling the wrong cpp file.

Upvotes: 2

Related Questions