DoubleLi

qq: 517712484 wx: ldbgliet

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

VS2019开发一个项目,报错:如下,

error LNK2001: unresolved external symbol __imp___CrtDbgReport 

error LNK2001: unresolved external symbol __imp___invalid_parameter

error LNK2001: unresolved external symbol __imp___CrtDbgReportW 

error LNK2001: unresolved external symbol __imp___CrtDbgReportW 

error LNK2001: unresolved external symbol __imp___CrtDbgReportW

error LNK2001: unresolved external symbol __imp___free_dbg 

error LNK2001: unresolved external symbol __imp___malloc_dbg

对应的中文版报错如下,
严重性    代码    说明    项目    路径    文件    行    禁止显示状态
错误    LNK2019    无法解析的外部符号 __imp__invalid_parameter,
错误    LNK2019    无法解析的外部符号 __imp__calloc_dbg,
错误    LNK2019    无法解析的外部符号 __imp__CrtDbgReport,
错误    LNK2019    无法解析的外部符号 __imp__free_dbg,
错误    LNK2019    无法解析的外部符号 __imp__malloc_dbg,
错误    LNK1120    5 个无法解析的外部命令    

看名称,应该是某个库找不到,但到底是哪个库呢?能过搜索后发现,是ucrtd.lib这个库。

具体可能考:

Visual Studio Feedback
Developer community 2
https://developercommunity.visualstudio.com/t/5-unresolved-external-symbols-when-linking-vc-proj/593359
其中有一段是这么说的,

The upgraded project is missing a reference to the Universal CRT, specifically ucrtd.lib. This library comes from the Windows 10 SDK and is part of the VS 2015/Windows 10 change which brings portions of the C-runtime into the OS. Details on this change and other potential issues you may find upgrading to VS 2015 and later can be found here:

Microsoft C++ porting and upgrading guide | Microsoft Docs

And the specific page related to the Universal CRT:

Upgrade your code to the Universal CRT | Microsoft Docs

From what I can tell, the following changes are needed to the supplied repro projects to resolve the link errors:

Add $(UniversalCRT_LibraryPath_x86) to Linker->General->“Additional Library Directories”
Add ucrtd.lib to Linker->Input->“Additional Dependencies”
本文结束

posted on 2024-08-02 14:55  DoubleLi  阅读(19)  评论(0编辑  收藏  举报