__crt_debugger_hook在ucrtd.lib和msvcrtd.lib中定义? [英] __crt_debugger_hook defined in both ucrtd.lib and msvcrtd.lib?

查看:811
本文介绍了__crt_debugger_hook在ucrtd.lib和msvcrtd.lib中定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一个原生的C ++ Visual Studio 2010项目转换为Visual Studio 2015的过程中,在修复了一堆其他东西后,我终于在链接阶段失败,出现以下错误

  ucrtd.lib(ucrtbased.dll):错误LNK2005:__crt_debugger_hook已在msvcrtd.lib(utility_desktop.obj)中定义


根据dumpbin,符号 __ crt_debugger_hook 在这两个库中,在msvcrtd.lib中的符号表中。



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



有没有任何其他的想法可能是什么原因导致这个问题?

解决方案

事实证明,这个bug不在微软的库。而是位于Crypto ++( https://www.cryptopp.com/ )库中。他们转发声明 _crt_debugger_hook 的方式与微软在将c运行时拆分为ucrtd.lib和msvrtd.lib时所做的更改不兼容。第21行的冒犯行是fipstest.cpp:

  externC{_CRTIMP void __cdecl _CRT_DEBUGGER_HOOK(int);} 

需要移除 _CRTIMP

  externC{void __cdecl _CRT_DEBUGGER_HOOK(int); } 

我已经使用Crypto ++开发了一个pull请求来修复这个问题( https://github.com/weidai11/cryptopp/pull/151 )。


I'm in the process of converting a native C++ Visual Studio 2010 project to Visual Studio 2015 and after fixing a bunch of other stuff I'm finally at the linking stage which is failing with the following error

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

Thinking it may be a C-runtime library mismatch I went back and recompiled all our dependencies using VS2015 and the /MDd switch to control which run-time is used. That didn't fix anything.

According to dumpbin the symbol __crt_debugger_hook is in both libraries, but it only appears in a symbol table in msvcrtd.lib.

There are other executables in my solution that link with ucrtd.lib and msvcrtd.lib yet don't suffer from this problem. The executable that does experience the link failure also links with MFC and BCG, but I don't see how that could be the cause.

Does anyone have any other ideas for what could be causing this problem?

解决方案

It turns out that the bug isn't in Microsoft's library. Instead it's in the Crypto++ (https://www.cryptopp.com/) library. They forward declare _crt_debugger_hook in a way that is incompatible with changes that were made by Microsoft when they split the c-runtime into ucrtd.lib and msvrtd.lib. The offending line is fipstest.cpp at line 21:

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

the _CRTIMP needs to be removed so that you have

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

I've opened a pull request with the Crypto++ folks to fix this (https://github.com/weidai11/cryptopp/pull/151).

这篇关于__crt_debugger_hook在ucrtd.lib和msvcrtd.lib中定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆