Where does Visual Studio look for C++ header files?
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 (Project -> [project name] Properties, under C/C++ | General).
- In the Visual Studio C++ Include directories under Tools → Options → Projects and Solutions → VC++ Directories.
- In new versions of Visual Studio (2015+) the above option is deprecated and a list of default include directories is available at Project Properties → Configuration → VC++ Directories
In your case, add the directory that the header is to the project properties (Project Properties → Configuration → C/C++ → General → Additional Include Directories).
Actually On my windows 10 with visual studio 2017 community, the C++ headers path are:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt
The 1st contains standard C++ headers such as <iostream>
, <algorithm>
. The 2nd contains old C headers such as <stdio.h>
, <string.h>
. The version number can be different based on your software.
Hope this would help.
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.