为什么 MSCVRT 库在链接时会产生冲突?

发布于 2024-08-27 23:35:19 字数 696 浏览 3 评论 0原文

我正在 Visual C++ 2008 中构建一个项目,这是一个基于 MFC 的静态 C++ 类库应用程序示例,我很快将在我自己的项目中使用。在构建调试配置时,我得到以下信息:

警告 LNK4098:defaultlib“MSVCRT”与其他库的使用冲突;使用 /NODEFAULTLIB:库

使用推荐的选项(通过在调试配置的项目链接器设置中的“忽略特定库”字段中添加“msvcrt”)后,程序链接并运行良好。但是,我想找出为什么会发生这种冲突,为什么我必须忽略一个关键库,如果我预计以后会出现问题,我是否添加忽略,或者如果我不添加会发生什么(因为无论如何,程序都会构建)。

同时,Release配置警告:

警告 LNK4075:由于“/OPT:ICF”规范而忽略“/EDITANDCONTINUE”
警告 LNK4098:defaultlib“MSVCRTD”与其他库的使用冲突;使用 /NODEFAULTLIB:库

我猜测“D”后缀意味着这是 vc++ 运行时的调试版本,不知道为什么这次使用它。无论如何,将“msvcrtd”添加到忽略字段会导致大量以下形式的链接错误:

错误 LNK2001:无法解析的外部符号 __imp___CrtDbgReportW

非常感谢任何见解。

I am building a project in Visual C++ 2008, which is an example MFC-based app for a static C++ class library I will be using in my own project soon. While building the Debug configuration, I get the following:

warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library

After using the recommended option (by adding "msvcrt" to the "Ignore specific library" field in the project linker settings for the Debug configuration), the program links and runs fine. However, I'd like to find out why this conflict occured, why do I have to ignore a critical library, and if I'm to expect problems later I if add the ignore, or what happens if I don't (because the program builds anyway).

At the same time, the Release configuration warns:

warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specification
warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library

I'm guessing that the "D" suffix means this is the debug version of the vc++ runtime, no idea why this gets used this time. Anyway, adding "msvcrtd" to the ignore field causes lots of link errors of the form:

error LNK2001: unresolved external symbol __imp___CrtDbgReportW

Any insight greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

愿与i 2024-09-03 23:35:19

当您链接到使用另一个版本的 VC++ 运行时的静态库(项目属性中的C++ ->代码生成->运行时库设置)时,通常会发生这种情况。

This usually happens when you link against a static library that uses another version of the VC++ runtime (C++ ->Code Generation->Runtime Library setting in the project properties).

冷月断魂刀 2024-09-03 23:35:19

当我(无意中)混合不同风格的 RTL 时,通常会发生这种情况,例如(在您的情况下)调试和发布或 MT 和 ST。

This usually happened to me when I was (inadvertently) mixing different flavours of the RTL, like (as it seems to be in your case) Debug and Release or MT and ST.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文