14

When building a static library (.LIB) in MS Visual Studio 10 with debug information, the .PDB is always named vc100.pdb.
(as opposed to building a .DLL, where the debug info is [MyProjectName].pdb)

This is a problem for me because I'm trying to copy several different libraries (and their debug symbols) to a directory of "PublishedLibraries", but all the vc100.pdb names obviously collide.

I'm sure I can change the names of each .PDB to match its .LIB, but for me the bigger question is why does Visual Studio think vc100.pdb is a better name than projectA.pdb??
How are we intended to work with Debug Info from multiple libraries if all the names conflict?

abelenky
  • 63,815
  • 23
  • 109
  • 159
  • 1
    err, how you debug a .lib directly? IMO if you build it into a DLL or exe the .pdb for that will have everything needed to debug. – Balog Pal Jun 11 '13 at 19:55
  • 1
    If I build several libraries (and some other code) into an executable, does not that executable need information from the various `vc100.pdb` files? How does it read them all if they all have the same conflicting name? – abelenky Jun 11 '13 at 19:58
  • 1
    It is the "program database", it contains dependency information. Leave it where it was generated. The PDB you need doesn't get generated until you link the static library into an executable. – Hans Passant Jun 11 '13 at 20:00
  • 1
    @HansPassant : Are you saying that the debug information (that I would otherwise expect to find in a `.PDB`) is in the `.LIB` file? – abelenky Jun 11 '13 at 20:01
  • @abelenky: the usual settings put them in distinct dirs, so there is no clash. I'm not really sure how it's done as long as the end result just works ;-) – Balog Pal Jun 11 '13 at 20:01
  • @BalogPal: It is true that the libraries are originally built to separate directories. But it is totally reasonable to want to collect finished libraries in one common `Libraries` folder so other programs can link against all libraries there. That introduces the problem I'm having. – abelenky Jun 11 '13 at 20:12
  • @abelenky: it's reasonable only if you "ship" the libs rather than build them in the .sln, and in projects using them add the lib project refernce rather than the .lib itself. Also IIRC there is a project option to set the pdb name to $(Projname).pdb, don't have a compiler around to check. – Balog Pal Jun 11 '13 at 20:23

1 Answers1

21

If you use /Z7 (instead of /ZI or /Zi) [ in the UI C/C++ -> General -> Debug Information Format] then the debug information is embedded in the lib file itself, instead of a separate pdb, which means you don't need to worry about the same name.

When you build your final executable (.exe or .dll) then you'll get a merged pdb from all the little embedded pdbs.

see this question for more info

Its the way I've always managed this issue on my team, as you can't lose the debug information during the build process. It bloats the libs somewhat [but no more in total than having both lib and pdb], but as you probably don't ship libs you shouldn't worry to much about this.

Community
  • 1
  • 1
Mike Vine
  • 9,468
  • 25
  • 44