Include stdlib.h :No such file or directory in vc++
Solution 1
If you compile from the command-line, you should use the Visual Studio Command Prompt
as it sets common environment variables that are used for compiling.
If for some reason you insist on using cmd.exe
then you have to either add the include paths to the INCLUDE
environment variable or you have to give the compiler the command-line parameter /IC:\Path\to\include
Details are available on MSDN
edit: well since this got recently upvoted I might as well add what I forgot last time. If you want to set up the environment variables that the Visual Studio Command Prompt
uses you can just execute the vcvarsall.bat
which is located in a directory like C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC
for details consult the relevant MSDN page
Solution 2
Make sure you have the right platform toolset selected.
Project -> properties -> configuration properties -> Platform toolset
If you move a project from computer to computer via a flash drive or something, it can have an invalid toolset selected. That can cause intellisense to tell you that.
Karai
Updated on November 21, 2020Comments
-
Karai over 3 years
I compiled my c++ program in the directory
D:\Program Files\Microsoft Visual Studio 9.0\VC\bin
But stdlib.h is present in the path.
D:\Program Files\Microsoft Visual Studio 9.0\VC\include
While compiling my program, it throws the following error in the command prompt.
fatal error c1083:cannot open include file:"stdlib.h":No such file or directory NMAKE : fatal error U1077 :'.\c1.exe' : return code '0x2
How to solve this issue.Please take a look into it.
Thanks.'
-
Константин Ван almost 5 yearsIf you’re using Visual Studio build tool, run
Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat
oncmd
and it’ll set everything up on the console for you.