No CMAKE_C_COMPILER could be found in Windows Server 2012 R2 and VS2017
I'm using CMake 3.10.2 and faced issue on my computer LINK : fatal error LINK1104: cannot open file 'ucrtd.lib'
.
-- Building for: Visual Studio 15 2017
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:3 (project):
No CMAKE_C_COMPILER could be found.
CMake Error at CMakeLists.txt:3 (project):
No CMAKE_CXX_COMPILER could be found.
-- Configuring incomplete, errors occurred!
Here is my system information
System: Windows Server 2012 R2
Compiler: Visual Studio 2017 15.5.6, with VC is v141
Windows SDK: Windows10 SDK 10.0.16299.0, and also have Windows 8.1 SDK
I have did some testing on this issue. Firstly, I have 3 machine, one is Windows Server 2016, one is Windows 10 and the other 1 is Windows Server 2012 R2.
Both the 2016 and 10 can build sucessfully. The Windows Server 2016 installed VS2013 and VS2015 and VS2017, and may have other settings. The Win10 machine is a clean machine, excepted it installed VS2013, VS2015 and VS2017.
The Windows Server 2012 R2 machine is also a clean machine, excepted it installed VS2013 and VS2017.
I compared the CompilerIdC.vcxproj
in these three machine, the different is that the Windows Server 2012 R2
do not have such section <WindowsTargetPlatformVersion>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{CAE07175-D007-4FC3-BFE8-47B392814159}</ProjectGuid>
<RootNamespace>CompilerIdC</RootNamespace>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
</PropertyGroup>
....
</Project>
When I add <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
to CompilerIdC.vcxproj
, then msbuild CompilerIdC.vcxproj
works on the Windows Server 2012 R2
machine, otherwise, it reported LINK : fatal error LINK1104: cannot open file 'ucrtd.lib'
.
It seems due to some system different or something else, the cmake
can not generate the WindowsTargetPlatformVersion
section.
Could you give me some suggestion to mitigate it? Or what kind of detail information should I provide?