Where is Visual Studio looking for C ++ header files?

I checked a copy of the C ++ application from SourceForge (HoboCopy, if you're interested) and tried to compile it.

Visual Studio tells me that it cannot find a specific header file. I found the file in the source tree, but where should I put it so that it is found at compilation?

Are there any special directories?

+82
c ++ visual-studio header
Dec 02 '08 at 20:49
source share
6 answers

Visual Studio looks for headers in the following order:

  • In the current source directory.
  • In the "Additional Directories" section of the project properties ("Project Properties โ†’ [project name]" in the "C / C ++ | General" section).
  • In Visual Studio C ++, Include directories under Tools โ†’ Options โ†’ Projects and Solutions โ†’ V C ++ Directories.
  • In new versions of Visual Studio (2015+), the above option is deprecated, and the list of directories to be included by default is available in Project Properties โ†’ Configuration โ†’ V C ++ Directories

In your case, add the directory with the title to the project properties (Project Properties โ†’ Configuration โ†’ C / C ++ โ†’ General โ†’ Additional Include Directories).

+100
Dec 02 '08 at 20:55
source share

If the project comes with a Visual Studio project file, then it should already be configured to search for headers for you. If not, you will need to add the include file directory to the project settings by right-clicking on the project and selecting "Properties", pressing "C / C ++" and adding the directory containing the included files to the "Additional inclusion directories".

+11
Dec 02 '08 at 20:54
source share

Actually, in my windows 10 with the visual studio 2017 community, the C ++ header path is:

  1. C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include

  2. C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt

The first contains standard C ++ headers such as <iostream> , <algorithm> . The second contains old C headers such as <stdio.h> , <string.h> . The version number may vary depending on your software.

Hope this helps.

+8
Oct 03 '18 at 14:49
source share

I tried to add this as a comment on Rob Prouse , but the lack of formatting made it incomprehensible.

In Visual Studio 2010, the dialog box "Tools | Options | Projects and Solutions | VC ++ Directories" reports that "Editing VC ++ directories in" Tools ">" Options is "outdated", suggesting the use of a rather intuitive Property Manager.

If you really want to update the default value (IncludePath), you need to hack the corresponding entry in one of the XML files:

\ Program Files (X86) \ MSBuild \ Microsoft.Cpp \ v4.0 \ Platforms \ Win32 \ PlatformToolsets \ V100 \ Microsoft.Cpp.Win32.v100.props

or

\ Program Files (X86) \ MSBuild \ Microsoft.Cpp \ v4.0 \ Platforms \ x64 \ PlatformToolsets \ v100 \ Microsoft.Cpp.X64.v100.props

(May not be recommended by Microsoft).

+6
Feb 23 '12 at 10:16
source share

There seems to be a bug in the Visual Studio 2015 community. For a 64-bit project, the include folder is not found, unless it is in the list of optional Include Folders packages in win32.

+5
Feb 25 '16 at 22:48
source share

There is a newer question that best affects the problem. How do I enable paths in Visual Studio?

There is a way to do this in new versions of VisualStudio

  • only in the current project (as the question is asked here), and also
  • for each new project by default

Secondly, what Steve Wilkinson explains explains that, in his opinion, is not what Microsoft recommended.

To say it the short cut here: do it, but do it in the User-Directory in

C: \ Users \ username \ AppData \ Local \ Microsoft \ MSBuild \ v4.0

in xml file

Microsoft.Cpp.Win32.user.props

and / or

Microsoft.Cpp.x64.user.props

and not in the C: \ program files directory - where it is assumed that an unmodified Microsoft Factory-File will be located.

Then you do it the way VisualStudio does it too, and everything is regular.

For more on how to do this, see my answer there .

+3
Feb 24 '16 at 1:52
source share



All Articles