栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

VS2019: LNK2019 无法解析的外部符号

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

VS2019: LNK2019 无法解析的外部符号

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 FeedbackDeveloper community 2https://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”

本文结束

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/954401.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号