Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2015 cl Can't find CRT libs (stdio.h, ctype.h etc.) when building on command line

  • 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\
like image 763
Nilay Kothari Avatar asked Aug 06 '15 17:08

Nilay Kothari


3 Answers

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.

like image 153
AhmedBM Avatar answered Nov 12 '22 06:11

AhmedBM


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)

like image 42
전송현 Avatar answered Nov 12 '22 05:11

전송현


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

like image 4
zwcloud Avatar answered Nov 12 '22 07:11

zwcloud