如何处理Visual Studio中的第三方C ++库LNK4099警告 [英] How to deal with 3rd party c++ libraries LNK4099 Warning in VisualStudio

查看:930
本文介绍了如何处理Visual Studio中的第三方C ++库LNK4099警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Visual Studio c ++项目,在其中使用了链接器设置

I have a Visual Studio c++ project where I use the linker Settings

/WX (TreatWarningsAsLinkerErrors=true)

在Debug中,我使用/Zi(调试数据库)进行编译,效果很好.

In Debug, I compile with /Zi (Debug Database), which works fine.

现在我有一个第三方SDK,该SDK带有一个静态库,但没有.pdb文件. 在Debug中链接此文件后,我立即获得

Now I have a 3rd party SDK which comes with a static library, but no .pdb file. As soon as I link this file in Debug, I get

LNK4099: 3rd-party.lib(3rd-party.obj) : warning LNK4099: PDB "vc90.pdb" was not found "3rd-party.lib(3rd-party.obj)" or with "C:\OutDir\vc90.pdb"

请注意,此消息具有误导性,因为将vc90.pdb放在3rd-party.lib旁边不能解决该问题,因为该3rd-party lib的源代码和pdb不可用,因此链接器将随后提供仍然抱怨.

Please note that this message is misleading, as placing vc90.pdb next to 3rd-party.lib does not solve the problem, because the source code and pdb of that 3rd-party lib is not available, so the linker would then still complain.

为了摆脱此链接器警告,我在这里有什么选择?

In order to get rid of this linker warning, what are my options here?

推荐答案

如果您使用VS post 2010(所以2012/2013/2015),最简单的方法是将/ignore:4099选项添加到链接器.应忽略此特定警告.确保在2012年之前明确忽略了此警告……它确实存在,但只是一种是的,但我们不在乎"警告.

Easiest way if you use a VS post 2010 (so 2012/2013/2015) is to add the /ignore:4099 option to the linker. Should ignore this specific warning. Sure that before 2012 this warning was specifically ignored... It existed but was a kind of "yeah but we do not care" warning.

更复杂的方法...如果您拥有精力/动力/高级用户勇气/Visual Studio 2010或更低版本[2008/VC6/...]" 实际上,您可以使用lib命令lib /list obj.lib提取链接期间使用的符号. 您将获得包含在lib中的obj的内容,您可以使用lib /extact ../path/to/my/obj命令将其提取. 然后,您必须使用dumpbin /section:.debug$提取debug部分,然后您将发现pdb问题...使用/fd命令可以正确地重新链接pdb. 不知何故,工作量很大.这是您可以在这里找到的简短摘要:

More complex way... If you have the "energy/motivation/advanced user courage/Visual studio 2010 or before [2008/VC6/...]" You can actually extract the symbols used during linking using the lib command lib /list obj.lib. You will obtain a lit of the obj included in the lib, that you can extract with the lib /extact ../path/to/my/obj command. THEN you have to extract the debug section using the dumpbin /section:.debug$ And there you will find the pdb problem... using /fd command you can relink correctly the pdb. It is somehow a lot of work. This is the short summary of what you can find here : https://cldoten.wordpress.com/2009/07/01/vs2008-fixing-the-warning-pdb-vc90-pdb-not-found/ Follow the link I gave carefully.

显然,ignore方法可能是最简单且问题较少的方法,尤其是在使用大量第三方库的情况下.

Obviously the ignore method is probably the easiest and less problematic, especially if you use a lot of third-party libraries.

这篇关于如何处理Visual Studio中的第三方C ++库LNK4099警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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