Search code examples
c++visual-studiostatic-linkingdebug-symbols

How to deal with 3rd party c++ libraries LNK4099 Warning in VisualStudio


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

/WX (TreatWarningsAsLinkerErrors=true)

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

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"

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?


Solution

  • 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.

    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.

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