CMake 无法打开“ucrtd.lib”
【解决方案1】:
正如this CMake 论坛中提到的,可能需要明确告诉 CMake 您安装了哪个特定的 Windows 版本。考虑到您安装了 10.0.17763.0 版本,包括以下定义会将 CMake 定向到该版本:
cmake -DCMAKE_SYSTEM_VERSION=10.0.17763.0
这里是docs 对应CMAKE_SYSTEM_VERSION。
【讨论】:
【解决方案2】:
如here 所述,如果您使用的是 VS2022,并且您安装的 Windows SDK 版本为 10.0.19041.0(在撰写本文时默认安装的是 VS2022),那么您可能遇到了这种情况。
这种情况下的解决方案是卸载该 SDK 版本并安装其他版本。
问题:用cmake编译时,显示No CMAKE_C_COMPLIER could be found。在cmakerror.log文件中显示"链接:错误 无法打开文件“ucrtd.lib”"
问题的原因是缺少某些组件。
解决方法:
重新打开VS2017安装包,选择修改
My problem is similar to this one: Problems generating solution for VS 2017 with CMake, but the solution doesn’t work for me.
When run cmake in Developer Command Prompt for VS 2017, I got the error (from CMakeError.log):
LINK : fatal error LNK1104: Cannot open file “ucrtd.lib” [E:\Projects\My Project\VS\CMakeFiles\3.14.4\CompilerIdC\CompilerIdC.vcxproj]
But the file ucrtd.lib is located in the Windows Kits folder.
echo %LIB%
D:\Program Files (x86)\Microsoft Visual Studio 2017 Community\VC\Tools\MSVC\14.16.27023\lib\x86;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x86;C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\ucrt\x86;C:\Program Files(x86)\Windows Kits\10\lib\10.0.17763.0\um\x86;
dir “C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\ucrt\x86” /w /b
libucrt.lib
libucrtd.lib
ucrt.lib
ucrtd.lib
And I also try to manually run the build command listed in the CMakeError.log, it succeeds, no error.
CL.e

文章描述了在使用CMake进行编译时遇到找不到ucrtd.lib文件的错误,解决方案包括更新CMake的系统版本设置,检查WindowsSDK的路径是否正确,特别是确保环境变量指向正确的WindowsKits目录。对于VS2017,可能需要更新或修改注册表中的WindowsKits安装根目录。同时,对于VS2022和特定版本的WindowsSDK,可能需要卸载并安装不同版本的SDK来解决问题。

2830

被折叠的 条评论
为什么被折叠?



