简体   繁体   中英

Reference error while compiling C file in VS2010 command-prompt

I have VS 2010 installed on my system and i was trying to compile a simple hello.c in VS command prompt. The compilation gave an error.

Fatal Error C1083: Cannot open include file: 'stdio.h' no such file, folder exist

Why this error is coming ?? Does VS2010 not include reference files/assemblies for C.

VS 2010 certainly does contain the standard headers. You should check that your command prompt environment is set up correctly. There should be an environment variable named INCLUDE that has a directory similar to the cfollowing (among other directories) in it:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE

that directory (the name may vary slightly, for example depending on if your machine is a 64-bit OS of not) should include stdio.h

If you don't have such a directory in your environment, then you're not setting up the environment correctly. You should use on of the "Visual Studio Command Prompt" shortcuts that VS installs, or simply run

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat

With the appropriate parameter to get the environment you want ( x86 or amd64 for example).

If the INCLUDE environment variable does have an entry like that, but the stdio.h file doesn't exist, then you might need to reinstall VS.

I had a similar problem as the OP the VC folder was missing most of the files. I tried both repairing and uninstalling/reinstalling VS 2010 but neither worked.

What worked for me was installing the Microsoft Visual C++ 2010 Redistributable Package (x86). Microsoft Visual C++ 2010 Redistributable Package (x86)

There are so many versions of so much Windows system code that it's easy for a path to become invalid.

In my case:

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include

and

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib

needed to be changed to::

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include

and

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib

ie v7.1A -> v7.0A (don't ask why, it just part of the everyday, tiresome task of dealing with Microsoft!).

I had the same problem. The file stdio.h did not exist in folder include. I removed VS 2010 using the Control Panel then reinstalled, but this didn't solve the problem.

I then used the VS 2010 installation CD to remove all of VS 2010, and manually removed anything leftover by Control Panel. I then installed VS 2010 professional again. The problem was solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM