18
  • I have installed the latest VS2015 Professional version.
  • Opened the Visual Studio command prompt and ran vcvars32.bat
  • wrote a simple helloworld.cpp program (includes stdio.h and prints "hello world")
  • tried cl helloworld.cpp

I get the following error:

c:\test>cl helloworld.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

helloworld.cpp
helloworld.cpp(1): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory

The include paths set by the vcvars32.bat are:

INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE;C:\Program Files (x86)\Windows Kits\10\include\wdf\ucrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um;C:\Program Files (x86)\Windows Kits\10\include\wdf\shared;C:\Program Files (x86)\Windows Kits\10\include\wdf\um;C:\Program Files (x86)\Windows Kits\10\include\wdf\winrt;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE;C:\Program Files (x86)\Windows Kits\10\include\wdf\ucrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um;C:\Program Files (x86)\Windows Kits\10\include\wdf\shared;C:\Program Files (x86)\Windows Kits\10\include\wdf\um;C:\Program Files (x86)\Windows Kits\10\include\wdf\winrt;

Note that the paths in the environment variable are "C:\Program Files (x86)\Windows Kits\10\include\wdf\winrt;" etc. However, the actual location of the files is C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\winrt;

Am I doing something wrong here? Any help greatly appreciated.

p.s. My real purpose is to build the boost 1.58 library (but it suffers from the same issue as above, so first wanted to isolate the problem).

p.p.s. I noticed the following environment variables. But I'm unable to change them.

WindowsSDKLibVersion=wdf\
WindowsSDKVersion=wdf\
Nilay Kothari
  • 181
  • 1
  • 1
  • 3
  • Do you have stdio.h in one of those directories? – Joel Aug 06 '15 at 17:59
  • Yes. The files are all there in the correct places in include\10.0.10240.0, however not in include\wdf – Nilay Kothari Aug 06 '15 at 18:29
  • The vcvars script assumes that only version numbers appear in the include subdirectory. If something has installed something else there than either it's broken or the script is. If you've done this manually then you should undo it. – Ross Ridge Aug 06 '15 at 21:24
  • 1
    Also noted that **#include "stdio.h"** and **#include** are different. – Joel Aug 07 '15 at 00:07
  • @RossRidge Thanks for the reply. "wdf" is in include\ folder along with 10.0.240.0. I haven't copied it there. I got there when installed Visual Studio 2015, SDKs, Tools, WDK stuff etc. (not sure which installer caused it to go there.). The problem is in the vcvarsqueryregistry.bat (called by vcvars32.bat). That's where the logic of determining the SDK version is. It lexically sorts the folders under "include" folder and finds "wdf". As I'm not using WDF (Windows Driver Framework) right now, I've renamed the folder to 00wdf and it works for now. I've raised as bug on MSDN website. – Nilay Kothari Aug 07 '15 at 14:00
  • Yah, it appears to be an incompatible with how WDF installs itself and how vcvars detects the version of the Windows SDK. – Ross Ridge Aug 07 '15 at 15:06
  • For anyone else that encounters this problem here's the related bug report on Microsoft Connect: https://connect.microsoft.com/VisualStudio/Feedback/Details/1656623 – Ross Ridge Aug 12 '15 at 18:23
  • @chrisb Does [this solution](https://stackoverflow.com/a/32897691/4326278) help? – bogdan Apr 17 '17 at 09:33
  • I supose you are including and not "stdio.h" – LeDYoM Apr 23 '17 at 15:25

4 Answers4

16

If you have WDK (Windows Driver Kit - 10.0.26639) installed you will encounter this issue as the include paths are overwritten by the WDK. To get this to work, you must uninstall the WDK and it should work.

Ishmaeel
  • 14,138
  • 9
  • 71
  • 83
AhmedBM
  • 1,202
  • 17
  • 15
7

In my case, I added these paths to the additional include path:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\ucrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Include\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\winrt;$(IncludePath)

and added these paths to the additional lib path:

C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10586.0\um\x86;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10586.0\ucrt\x86;$(LibraryPath)

전송현
  • 71
  • 1
  • 2
  • Is it possible to combine 14 VC-includes and 10 SDK? – chris Dec 25 '16 at 13:52
  • fascinatingly crappy way to solve the problem, but it works. Yay microsoft and workarounds for their screwups. Thank you very much, build saver. :-) – stu Dec 28 '16 at 19:04
  • 1
    this solves problem for VC-2017 on Windows 10 while having installed WDK 8.1 and 10 – harmonickey Mar 31 '17 at 03:51
5

I ran into a similar problem on VS2017 (15.5.5) when building VC++ projects against Windows SDK 8.1:

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

Checking Windows 8.1 SDK and UCRT SDK in the VS installer solved the problem. Windows 8.1 SDK and UCRT SDK

zwcloud
  • 4,546
  • 3
  • 40
  • 69
1

I ran into a similar problem on VS2022 when building VC++ projects against
Windows SDK.
You need to open "Visual Studio Installer" and modify the components.
To get this to work, you must uninstall
Windows Universal CRT SDK
and it should work.
enter image description here

Yurii
  • 11
  • 2