In VS2010 there is an option to generate debug info for exes/dlls under linker but no such option under librarian for libs. Is the debug info embedded in t
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.
I wouldn't advise distributing a static library, however, since it's generally tied to a specific version of the compiler.
Expanding upon previous answers, for those who need the full how-to (VS 2013 minimum).
Note that this should address comments ^^above regarding VS2013 issues.
Method 1: The Program Database (.pdb) Way (/Zi or /ZI)
Static Lib Project: Generate a pdb with same name as your static lib:
Solution Explorer
from the View
menu.Properties
Configuration Properties
->C/C++
->General
->Debug Information
to /Zi
or /ZI
/ZI
allows "Edit and Continue" editing during debugging Configuration Properties
->C/C++
->Output Files
->Program Database File Name
to $(OutDir)$(TargetName).pdb
Application Project: Link your executable with the static lib, and new PDB file:
Debug Information
property as needed.Configuration Properties
->Linker
->General
->Additional Library Directories
, adding your own "libs" directory, or whatever directory you plan to keep/copy your YourLib.lib and YourLib.pdb files.Configuration Properties
->Linker
->Input
->Additional Dependencies
, adding YourLib.lib
(no path in front)Method 2: The Embedded Symbols (no .pdb) Way (/Z7)
Static Lib Project: Generate a static lib with embedded debug symbols
Debug Information
, but this time to/Z7
Application Project: Link you executable with the static lib
Debug Information
property as neededAdditional Library Directories
Additional Dependencies
Additional Library Directories
Discussion:
Debug Information
Setting for Application Project? This post is concerned with how to get debug working in static lib code. The same "Method 1 vs Method 2" choice applies for the Application project as well.I notice in VS2013 it is possible to set the program database file name in the C/C++ Output Files tab. Changing it from the default to something like $(OutDir)$(TargetName).pdb resolves the issue
Weird behavior in VS2012. Building from scratch (or with /A option in nmake) will produce a .pdb file. Now delete the .lib and .pdb and rerun nmake (without /A of course, to run only link) and no .pdb file is output.
Static libraries are implemented into the programs that use them.
If the program that uses them is using debug symbols, the compiled library code in that program will have symbols too.
PDB info from wikipedia:
When debug symbols are embedded in the binary itself, the file can then grow significantly larger (sometimes by several megabytes). To avoid this extra size, modern compilers and early mainframe debugging systems output the symbolic information into a separate file; for Microsoft compilers, this file is called a PDB file.