C1083: Cannot open include file: math.h: No such file or directory

I have a bunch of these errors, and I'm at a dead end.

Found many answers on google, but unfortunately none of them work

I am using Visual Studio 2012.

All the files that he says cannot be found 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 press "Open Document", it takes me to the document, so it is clearly there and can be seen

I tried to add the directory to the "Additional directories" field in the options, but did not solve it.

If I use the include statement with the full path as follows:

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

Then it works, but if there are any include statements in the math.h file, I also need to add a path to them, etc.

Any idea what is going on and what else can I try?

EDIT: Try creating a new project from scratch and see if that helps. Perhaps I touched on settings that I would not have

+7
c ++ include visual-studio
source share
3 answers

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

If the field is already checked, and Visual Studio does not find the directories, try adding these directories yourself:

 $(VCInstallDir)include $(VCInstallDir)atlmfc\include $(WindowsSDK_IncludePath) 
+7
source share

The following actions are incorrect in several ways:

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

\... the so-called escape sequence begins, so you put the special tokens \P , \M , \V , \i and \M on this line, but unlike, for example, \n , which denotes a newline, they do not exist as valid escape sequences. This can be fixed using a constant slash:

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

However, math.h is the standard header. For standard headers, you do not write the full path. For custom headers, you add an include path to the project settings and do not write the full path.

 #include <math.h> 

Then: you are in C ++, not C. C ++ equivalents of C headers usually have a .h extension, and a c added to the front:

 #include <cmath> 
+2
source share

I had the same problem and my solution was to simply put the file name in quotation marks instead of angle brackets.

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

+1
source share

All Articles