CMake 无法打开“ucrtd.lib”

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

开发板推荐:天空星STM32F407VET6开发板

超高性价比 STM32主控 | 超高主频 | 一板兼容百芯 | 比赛神器 | 沉金彩色丝印

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

开发板推荐:天空星STM32F407VET6开发板

超高性价比 STM32主控 | 超高主频 | 一板兼容百芯 | 比赛神器 | 沉金彩色丝印

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lst0426

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值