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

…衆ロ難τιáo~ 提交于 2019-11-29 06:37:38

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)

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>

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!