67

I've just installed Visual Studio 2015 on my working laptop with Windows 10.

I've cloned a repository with a solution created with the same version of Visual Studio (update 3) on another PC, always with windows 10.

When I try to build the solution on my laptop I obtain the following error:

c:\program files (x86)\microsoft visual studio 14.0\vc\include\crtdefs.h(10): fatal error C1083: Cannot open include file: 'corecrt.h': No such file or directory

In this page I've read that I must add $(UniversalCRT_IncludePath) to my include paths, but even in this case I obtain the same error.

I've checked and $(UniversalCRT_IncludePath) refers to this path:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt

This path is missing on my laptop. Instead I've this one:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt

So it seems that window version is different. Probably this is true, because on my laptop I didn't installed the 1511 windows updgrade, while in the other pc is all installed correctly.

My question is how can I refer to corecrt.h file in both pc without make a mess with paths. I'd like to avoid to hard-link these path because they are pc dependent. and I don't understand why in my laptop the path is wrong considering that it should be system dependent and not cabled into solution.

How can I solve this issue? I know that I can update my laptop to the same windows version but I'd like to avoid it for many reasons.

-- EDIT

I've noticed that that I have this path:

C:\Program Files (x86)\Windows Kits\8.1\Include\10.0.10240.0\ucrt

It has the same 10.0.10240.0 version but related to another windows kit version, so maybe there's some problem in this case. On my laptop I've also Visual Studio 2013, so maybe it can came from it, but I cannot remove it because I'm maintaining another project with Visual Studio 2013 and I cannot remove it yet.

Maybe in Visual Studio 2015 folder I can set explicitly the $(UniversalCRT_IncludePath) in some .bat file (vcvarsall.bat or similiar) but I don't know which file and in which position.

Jepessen
  • 11,744
  • 14
  • 82
  • 149

15 Answers15

139

For Visual Studio 2017 I had to:

  1. Run Visual Studio Installer.
  2. Select Modify button.
  3. Go to "Individual Components" tab.
  4. Scroll down to "Compilers, build tools and runtimes".
  5. Tick "Windows Universal CRT SDK".
  6. Install.
parsley72
  • 8,449
  • 8
  • 65
  • 98
  • 1
    Confirmed this fixed and was the best with with 2017 Enterprise. – TravisWhidden Jun 01 '17 at 17:10
  • 4
    If you've deleted your installation exe, just go into Add/Remove Programs > Right click on Microsoft Visual Studio > Modify. – Janac Meena Jul 07 '17 at 14:56
  • 2
    The parsley72 solution works also with the Community edition of Visual Studio 2017. So I guess it's essential with all versions. By the way CRT means **C** **R**un**T**ime. – Patapoom Aug 07 '17 at 08:33
  • 2
    What's the difference between "Windows Universal CRT SDK" (item 5 above) and "Windows Universal C Runtime" listed under individual components "SDKs, libraries, and frameworks"? – ThatsRightJack Sep 20 '17 at 04:24
  • 1
    @ThatsRightJack: The SDK is needed to compile the program (contains the .h file and the import lib), the runtime contains just the DLL needed to run the program. – MSalters Mar 05 '20 at 16:58
  • Sadly this doesn't always fix the issue. In my case I did install both Win 8 SDK as well as the bloatware Win Universal CRT SDK and the file can still not be found anywhere in my system. I tried looking into Win 10 SDK but same result. – rbaleksandar Aug 05 '21 at 07:19
31

you probably fixed this already, but if someone else comes along, i solved this by following the tip here.

Basically set the following system environment variables:

INCLUDE="C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt"
LIB="C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x64"

There is probably a much better best-practice way of doing it, but for just fixing it super-fast, this worked great.

Mark H
  • 585
  • 3
  • 11
Helge S
  • 561
  • 4
  • 4
7

I had the same problem. I tried the answers here. It didn't work 100%. What I found is that the VC++ 2015 toolset (x86, x64) is necessary for the 2017 Community Edition (which I am using now), but without adding any include or lib links.

Best regards.

Cyril Graze
  • 3,881
  • 2
  • 21
  • 27
Amr1318
  • 71
  • 1
  • 2
6

Maybe there was something missing while installing the Visual Studio. You can check whether you forgot to choose the VC++ toolset.

  1. Control Panel -> All Control Panel Items -> Programs and Features -> Visual studio 2015
  2. Click change/uninstall
  3. Choose the VC++2015 toolset(x86,x64) and install.

For Visual Studio Community 2017 RC(15.0.26206.0), the name of optional tool is VC++ 2017 v141 toolset(x86,x64):

`VC++ 2017 v141 toolset(x86,x64)

BioGeek
  • 21,897
  • 23
  • 83
  • 145
simondoo
  • 69
  • 1
  • 2
5

Try checking the projects properties (Menu Project > Properties). Under Configuration Properties > General, then check the Platform Toolset and Windows SDK Version (if using Platform Toolset > VS2015) After setting Platform Toolset = VS2017 and Windows SDK Version = 10.x.x it worked for me.

dvidben
  • 51
  • 1
  • 2
3

The reason of error could possibly could be because you don't have the updated version of windows 10 sdk

you can also download and install window 10 sdk autonomously,

using this link windows 10 sdk, and add it into your system path

hope it helps.

Khan
  • 1,288
  • 12
  • 11
3

The Windows SDK you have selected in your project isn't installed.

Visual Studio project setting windows SDK version 8.1

Either install the SDK you want or select one of installed ones (note: selecting <inherit from parent> option will default to 8.1, which isn't installed by default in VS 2017+)

To install the Windows SDK, run the installer and go to Individual components and scroll to the very bottom:

Visual Studio installer - individual components - windows 8.1 SDK

rustyx
  • 80,671
  • 25
  • 200
  • 267
2

For Visual Studio 2015 Enterprise, I solved the problem in a similar way as parsley72:

1. Run the Visual Studio Installer;
2. Select Modify button;
3. Go to "Windows and Web Development";
4. Tick "Universal Windows App Development Tools";
5. Install.
Vitality
  • 20,705
  • 4
  • 108
  • 146
2
I find Reason that : Windows Registry

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots]
"KitsRoot10"="C:\\Program Files\\Windows Kits\\10\\"

but in Actually 
"KitsRoot10"="C:\\Program Files (x86)\\Windows Kits\\10\\"
"AppVerifier64BitAutomationRoot"="C:\\Program Files\\Application Verifier\\"
"KitsRoot81"="C:\\Program Files (x86)\\Windows Kits\\8.1\\"

see:Where is WindowsSDK_IncludePath defined?

高亚斌
  • 71
  • 1
  • 3
1

For me helps this setting in Visual Studio:

  • in Project properties -> VC++ Directories -> Include Directories -> open for edit.
  • check checkbox Inherit from parent or project defaults
Libor B.
  • 519
  • 5
  • 9
1

I just got this error while compiling PyTorch on Windows and installing Windows Universal CRT SDK didn't resolved it. After fiddling around it seems there are two causes:

  1. Make sure you run vcvarsall.bat. When you start VS2017 x64 Native Command Prompt, it does run this bat file.
  2. Set vcvars_ver to correct version that is on your machine. To find the version you have, go to %PROGRAMFILES(X86)%\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\. Inside this folder you will see folder such as 14.13.26128. So you set vcvars_ver to 14.13.

Below fragment in my batch file shows above two steps:

set "VS150COMNTOOLS=%PROGRAMFILES(X86)%\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build"
call "%VS150COMNTOOLS%\vcvarsall.bat" x64 -vcvars_ver=14.13
Shital Shah
  • 63,284
  • 17
  • 238
  • 185
  • 1
    Thank you very much! This is the answer that saved my day! Actually I got an error relating to installing Python packages via Pip , and the error is that the file "vcruntime.h" could not be found. I tried several solutions above but this is the one that worked for me! – Dang Manh Truong Jul 01 '19 at 15:34
0

Either add the older Windows SDK (ex. version 8.1 / Universal) to your machine (as described by parsley72), or re-target Project(s) to use one of the Windows SDK(s) installed on your computer.

I just ran into this with VS2017 and re-targeting worked. Though I'm still waiting for an answer on whether targeting a newer Windows SDK version has any ill effects.

codesniffer
  • 1,033
  • 9
  • 22
0

I resolve this error by the next 3 step.

1) All file from:

C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x86
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x86

Copy to:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\VS\lib\x86

2) All file from:

C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x64
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x64

Copy to:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\VS\lib\x64

3) All File from:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt

Copy to:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\VS\include

Then I rebuild my project and all work properly

0

Reinstall windows 10 sdk , if you missing windows sdk or if its content changed this error will popup, it happend to me after installing wdk

Mahdi Khalili
  • 1,025
  • 15
  • 32
-1

I have no experience with VC++ but I have to build ta-lib for a python project. Since I do not want to touch anything in VC Studio but I have experienced with regular C programming under Unix, I have taken the approach of adding the include path directly in the Makefile; e.g.:

INCPATH = -I"..........\include" -I"..........\src\ta_common" -I"..........\src\ta_abstract" -I"..........\src\ta_abstract\tables" -I"..........\src\ta_abstract\frames" -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include"

There are multiple Makefiles under sub-directories so I have had to make changes to each one but it works alright for me.

hwase0ng
  • 84
  • 2