I checked out a copy of a C++ application from SourceForge (HoboCopy, if you’re curious) and tried to compile it.
Visual Studio tells me that it can’t find a particular header file. I found the file in the source tree, but where do I need to put it, so that it will be found when compiling?
Are there special directories?
Visual Studio looks for headers in this order:
- In the current source directory.
- In the Additional Include Directories in the project properties (under C++ | General).
- In the Visual Studio C++ Include directories under Tools → Options → Projects and Solutions → VC++ Directories.
In your case, add the directory that the header is in to the project properties.
If the project came with a Visual Studio project file, then that should already be configured to find the headers for you. If not, you’ll have to add the include file directory to the project settings by right-clicking the project and selecting Properties, clicking on “C/C++”, and adding the directory containing the include files to the “Additional Include Directories” edit box.
Tried to add this as a comment to Rob Prouse‘s posting, but the lack of formatting made it unintelligible.
In Visual Studio 2010, the “Tools | Options | Projects and Solutions | VC++ Directories” dialog reports that “VC++ Directories editing in Tools > Options has been deprecated”, proposing that you use the rather counter-intuitive Property Manager.
If you really, really want to update the default $(IncludePath), you have to hack the appropriate entry in one of the XML files:
(Probably not Microsoft-recommended.)
There seems to be a bug in Visual Studio 2015 community. For a 64-bit project, the include folder isn’t found unless it’s in the win32 bit configuration Additional Include Folders list.
There exists a newer question what is hitting the problem better asking How do include paths work in Visual Studio?
There is getting revealed the way to do it in the newer versions of VisualStudio
- in the current project only (as the question is set here too) as well as
- for every new project as default
The second is the what the answer of Steve Wilkinson above explains, what is, as he supposed himself, not the what Microsoft would recommend.
To say it the shortway here: do it, but do it in the User-Directory at
in the XML-file
and not in the C:\program files – directory, where the unmodified Factory-File of Microsoft is expected to reside.
Then you do it the way as VisualStudio is doing it too and everything is regular.
For more info why to do it alike, see my answer there.