Cannot find corecrt.h: $(UniversalCRT_IncludePath)

2019-01-13 12:15发布

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.

12条回答
别忘想泡老子
2楼-- · 2019-01-13 12:56

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

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-01-13 12:58

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.

查看更多
何必那么认真
4楼-- · 2019-01-13 12:59

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.

查看更多
时光不老,我们不散
5楼-- · 2019-01-13 13:00

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.
查看更多
别忘想泡老子
6楼-- · 2019-01-13 13:01

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.

查看更多
小情绪 Triste *
7楼-- · 2019-01-13 13:04

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
查看更多
登录 后发表回答