Search code examples
windowsvisual-studio

Are .pdb files required for .lib (static libraries) or are the dll/exe's pdb files enough?


I know, roughly, that when statically linking to a .lib from an .exe the code is placed in the .exe (missing some detail of course).

But when getting a stack trace from something like WinDbg, do i need to have a pdb for both the exe AND the lib, or will the pdb for the exe contain the information from the pdb for the lib (in the same way the exe contains the lib)?

I'm asking because in Debug building with MSVC (using CMake) I get pdbs for my .libs, .ddls, .exes but in release I can only get ones for the .dlls and .exes


Solution

  • Check this answer. There are compile options.

    If you use /ZI or /Zi (C/C++ -> General -> Debug Information Format), then the vc$(PlatformToolsetVersion).pdb is created, which contains the debug info for all of the .obj files created. If alternately you use /Z7, the debug info will be embedded into the .obj file, and then embedded into the .lib. This is probably the easiest way to distribute the debug info for a static library.