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

后端 未结 12 1720
误落风尘
误落风尘 2020-12-15 02:27

I am trying to Build a Solution on Visual Studio Community 2017, but I keep getting the error \"Cannot open include file: \'stdio.h\' \". I\'ve read through

相关标签:
12条回答
  • 2020-12-15 03:05

    If you run into this problem with Visual Studio 2019 (VS2019), you can download the build tools from https://visualstudio.microsoft.com/downloads/. And, under Tools for Visual Studio 2019 and download Build Tools for Visual Studios 2019.

    0 讨论(0)
  • 2020-12-15 03:06

    I had the same problem building VS 2013 Project with Visual Studio 2017 IDE. The solution was to set the right "Platformtoolset v120 (Visual Studio 2013). Therefor there must be the Windows SDK 8.1 installed. If you want to use Platformtoolset v141 (Visual Studio 2017) there must be Windows SDK 10. The Platformtoolset can be chosen inside the properties dialog of the project: General -> Platformtoolset

    0 讨论(0)
  • 2020-12-15 03:07

    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.

    0 讨论(0)
  • 2020-12-15 03:10

    Scenario:

    1. Windows 10 with Visual Studio 2017 (FRESH installation).

    2. 'C' project (ERROR like -> cannot open source file: 'stdio.h', 'windows.h', etc.).

    Resolve:

    1. Run 'Visual Studio Installer'.

    2. Click button 'Modify'.

    3. Select 'Desktop development with C++'.

    4. From "Installation details"(usually on the right-sidebar) select:

      4.1. Windows 10 SDK(10.0.17134.0).

      • Version of SDK in 4.1. is just for example.
    5. Click button 'Modify', to apply changes.

    6. Right-click 'SomeProject' -> 'Properties'.
    7. 'Configuration:' -> 'All Configurations' and 'Platform:' -> 'All Platforms'.
    8. 'Configuration Properties' -> 'General' -> 'Windows SDK Version':
      • change(select from combobox) SDK version to currently installed;
    9. Click button 'Apply', to apply changes.
    0 讨论(0)
  • 2020-12-15 03:18

    A dirty fix: Add $(VC_IncludePath);$(WindowsSDK_IncludePath); into project Properties / C/C++ / General / Additional include directories

    0 讨论(0)
  • 2020-12-15 03:20

    Got same problem with project porting from VS2013 to VS2017,
    Fix: change "Properties->General->Windows SDK Version" to 10

    0 讨论(0)
提交回复
热议问题