c++ - ucrtd.lib 和 msvcrtd.lib 中都定义了 __crt_debugger_hook?

标签 c++ visual-studio-2015

我正在将 native C++ Visual Studio 2010 项目转换为 Visual Studio 2015,在修复了一堆其他问题后,我终于进入了链接阶段,该阶段失败并出现以下错误

ucrtd.lib(ucrtbased.dll) : error LNK2005: __crt_debugger_hook already defined in msvcrtd.lib(utility_desktop.obj)

考虑到这可能是 C 运行时库不匹配,我返回并使用 VS2015 和/MDd 开关重新编译了所有依赖项以控制使用哪个运行时。那没有解决任何问题。

根据 dumpbin,符号 __crt_debugger_hook 存在于两个库中,但它只出现在 msvcrtd.lib 的符号表中。

我的解决方案中还有其他可执行文件与 ucrtd.lib 和 msvcrtd.lib 链接,但不会遇到此问题。遇到链接失败的可执行文件也与 MFC 和 BCG 链接,但我不明白这可能是什么原因。

是否有人对可能导致此问题的原因有任何其他想法?

最佳答案

事实证明,该错误不在 Microsoft 的库中。相反,它位于 Crypto++ ( https://www.cryptopp.com/) 库中。他们转发声明 _crt_debugger_hook 的方式与 Microsoft 在将 c-runtime 拆分为 ucrtd.lib 和 msvrtd.lib 时所做的更改不兼容。违规行是第 21 行的 fipstest.cpp:

extern "C" {_CRTIMP void __cdecl _CRT_DEBUGGER_HOOK(int);}

需要删除 _CRTIMP 以便您拥有

extern "C" {void __cdecl _CRT_DEBUGGER_HOOK(int); }

我已经向 Crypto++ 人员发起了一个拉取请求来解决这个问题 ( https://github.com/weidai11/cryptopp/pull/151 )。

关于c++ - ucrtd.lib 和 msvcrtd.lib 中都定义了 __crt_debugger_hook?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35734683/

相关文章:

c++ - 不情愿地通过 RPC 调用 QueryInterface

c++ - 为覆盖 std::exception 的库生成 swig 接口(interface)时出错

java - 如何归档 Java 和 C++ 应用程序之间的分布式(数据库)事务?

C++ 简单循环引用和前向声明问题

visual-studio-2015 - VS 2015 创建新项目或打开项目时出现错误 “Object reference not set to an instance of an object”?

c++ - Visual Studio 2012 上的 WildMagic 5.9

c++ - C++ 链表中的虚拟节点

c# - Visual Studio 2015 "Find All References"只搜索打开的文件

c++ - Wl,--stack,4194304 错误 Visual Studio/CMake

c++ - 新建 Win32 应用程序向导为空白