Cannot Open Include File: 'Stdio.H' - Visual Studio Community 2017 - C++ Error

Cannot open include file: 'stdio.h' - Visual Studio Community 2017 - C++ Error

There are three ways to solve this issue.

  1. Ignore Precompiled Headers #1
    Steps: Project > Properties > Configuration Properties > C/C++ > Command Line > in the Additional Options box add /Y-. (Screenshot of Property Pages) > Ok > Remove #include "stdafx.h"
  2. Ignore Precompiled Headers #2
    Steps: File > New > Project > ... > In the Application Wizard Window click Next > Uncheck the Precompiled Header box > Finish > Remove #include "stdafx.h"
  3. Reinstall Visual Studio
    This also worked for me, because I realized that maybe there was something wrong with my Windows SDK. I was using Windows 10, but with Windows SDK 8.1. You may have this problem as well.

    Steps: Open Visual Studio Installer > Click on the three-lined Menu Bar > Uninstall > Restart your computer > Open Visual Studio Installer > Install what you want, but make sure you install only the latest Windows SDK 10, not multiple ones nor the 8.1.

    The first time I installed Visual Studio, I would get an error stating that I needed to install Windows SDK 8.1. So I did, through Visual Studio Installer's Modify option. Perhaps this was a problem because I was installed it after Visual Studio was already installed, or because I needed SDK 10 instead. Just to be safe I did a complete reinstall.

Microsoft C++ Compiler, Fatal Error C1083: Cannot open include file 'stdio.h'

The include directories for the current session are stored in the INCLUDE environment variable.

You can view this by typing echo %INCLUDE% on the command prompt.

To add a directory to the include path, use the command set INCLUDE=%INCLUDE%;C:\foo\bar.

The fact, however, that the compiler isn't finding a standard and ubiquitous header like <stdio.h> indicates a serious problem with your Visual Studio installation. I would run a repair install if I were you.

Visual Studio 2017 for Dymola cannot open stdio.h

Just to complete this as I also had the problem that I had the admin rights, but no access to the registry, so that Dymola threw the compiler error. There are 2 possibilities:

  1. Get access to the registry from the IT.
  2. If this is not possible, due to ristrictions. Eiter install a tool that bypass the registry or change the paths manually, which I would recommand, as the tools are not so serious.

Here is the solution how to change the paths at least for VS2013. First of all, you need to open the vcvars32.bat from %ProgramFiles(x86)%\Microsoft Visual Studio 12.0\VC\bin\ in a texteditor that you have opened as admin. There you need to comment out the first 3 lines, which perform the not possible registry call that sets several paths. Afterwards, you need to set those paths manually in the vcvars32.bat. Finally, the beginning of the vcvars32.bat should look like this:

    :: @call :GetVSCommonToolsDir
:: @if "%VS120COMNTOOLS%"=="" goto error_no_VS120COMNTOOLSDIR

:: @call "%VS120COMNTOOLS%VCVarsQueryRegistry.bat" 32bit No64bit

@SET VSINSTALLDIR=%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\
@SET VCINSTALLDIR=%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\VC\
@SET FrameworkDir32=c:\Windows\Microsoft.NET\Framework\
@SET FrameworkVersion32=v4.0.30319
@SET Framework40Version=v4.0
@SET WindowsSdkDir=%ProgramFiles(x86)%\Windows Kits\8.1\
@SET ExtensionSdkDir=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v8.1\ExtensionsSDKs\
@SET WindowsSDK_ExecutablePath_x86=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\
@SET WindowsSDK_ExecutablePath_x64=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\

Perhaps, you need to slightly adapt some paths for your configuration.

For more information you can look here:

VS2010 command prompt gives error: Cannot determine the location of the VS Common Tools folder

Visual Studio 2017 Cannot open source file windows.h

I seem to have found the issue

Solved!

  1. Click Project (top)

  2. Click properties (bottom)

  3. Under configuration properties, Click General

  4. Under general, click windows SDK version. If it is at 10.x put it to 8.1 then close then put it back to 10.x again.

Seemed to work for me.



Related Topics



Leave a reply



Submit