14

I have a bunch of these errors and am at a dead end.

Found plenty of answers on google but unfortunately none of them work

I am using Visual Studio 2012.

All the files it says is cant find are on my computer in this folder

C:\Program Files\Microsoft Visual Studio 11.0\VC\include

Even when I right click on the include statement and click on 'Open Document ' it takes me to the document, so it is clearly there and can be seen

I tried adding the directory to the 'Additional Directories' field in options too but did not solve it.

If I use the include statement with the full path like so :

#include <C:\Program Files\Microsoft Visual Studio 11.0\VC\include\math.h>

Then is works but if the math.h file has any include statements I need to add the path to them as well and so on.

Any Idea what is happening and what else I can try?

EDIT: Going to try and create a new project from scratch and see if that helps. It is possible I touched a settings I shouldn't have

Mr Dog
  • 396
  • 1
  • 3
  • 22

5 Answers5

10

Right-click your project, go to Properties, then go to VC++ Directories and open the editor for Include Directories. There should be a tick box labelled "Inherit from parent or project defaults". You will see that Visual Studio includes some predefined directories.

If the box is already ticked and Visual Studio isn't finding the directories then try adding these directories yourself:

$(VCInstallDir)include
$(VCInstallDir)atlmfc\include
$(WindowsSDK_IncludePath)
Simple
  • 13,992
  • 2
  • 47
  • 47
  • Thanks for the reply. The Box is ticked and the 3 directories you stated are listed under 'Inherited values:' – Mr Dog Jun 12 '14 at 14:32
  • 1
    @Rio if you press the Macros button on that dialog, what does the `$(VCInstallDir)` macro expand to? – Simple Jun 12 '14 at 14:38
  • It points to "C:\Program Files\Microsoft Visual Studio 11.0\" – Mr Dog Jun 12 '14 at 14:42
  • @Rio mine points to "C:\Program Files\Microsoft Visual Studio 11.0\VC\". Try adding `$(VCInstallDir)vc\include` and `$(VCInstallDir)vc\atlmfc\include` yourself as workarounds. – Simple Jun 12 '14 at 14:49
  • Sorry about that, the window was cutting it out. The 'VC\' is there on mine as well. – Mr Dog Jun 12 '14 at 14:53
  • @Rio I can't think of anything else that could be the problem. :/ – Simple Jun 12 '14 at 15:10
  • Thank @Simple for the help. I ended up deleteing the project and recreating it from scratch and it solved it self. Looks like I might have just missed a setting while setting up – Mr Dog Jun 12 '14 at 19:58
  • That was unimaginably simple, and yet I would have probably never figured it out on my own. Apparently I had managed to turn it off in my x64 configuration and not my Win32. Who would have known. Thanks. – dagronlund May 06 '15 at 23:12
  • I found the system header files were moved for VS 2015, according to this: https://social.msdn.microsoft.com/Forums/vstudio/en-US/cfa48739-cd32-43d2-9d27-2b6653da6645/canf-find-standard-c-header-file-in-visual-studio-2015-community-version?forum=vclanguage . You have to specify `C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt` as the path -- at least, that's where I found them. Manually added this as above and was able to move on to new errors.. Related: http://stackoverflow.com/questions/31736361/visual-studio-2015-gives-me-errors-upon-creating-a-simple-test-console-program – vapcguy Mar 10 '17 at 18:52
5

The following is not correct in multiple ways:

#include <C:\Program Files\Microsoft Visual Studio 11.0\VC\include\math.h>

\... begins a so called escape sequence, therefore you are putting the special tokens \P, \M, \V, \i and \m into the string, but unlike for example \n, which denotes a the newline character, these do not exist as valid escape sequences. This can be fixed by using forward slash consistently:

#include <C:/Program Files/Microsoft Visual Studio 11.0/VC/include/math.h>

However, math.h is a standard header. For standard headers, you don't write the full path. For non-standard headers, you add the include-path to the project setup, and don't write the full path neither.

#include <math.h>

Then: You are in C++, not in C. The C++ equivalents of the C-headers usually have the .h extension removed, and a c appended to the front:

#include <cmath>
Sebastian Mach
  • 38,570
  • 8
  • 95
  • 130
2

I've just had the same problem, and my solution was simply to place the filename in quotes instead of angle brackets.

So, instead of < dog.h> , "dog.h" solved the "file not found" problem.

0

This is a bug in Visual Studio that Micosoft has set to "Closed - not a bug" see the link

https://developercommunity.visualstudio.com/content/problem/311530/win10-sdk-broken.html

I searched my PC for math.h and found it in a sub folder under "Program Files\Unity", i.e. Visual Studio did not install it. I seem to have the reverse midas touch this weekend, everything I touch turns to crap.

-1

Retarget the project under the solution properties.

Zhen Yang
  • 83
  • 9