I am getting confused as to what is the difference between the compiler and linker PDB files respectively (i.e. in Visual Studio, Project Properties > C/C++ > Output Files > Program Database File Name vs Project Properties > Linker > Debugging). I have tried to find the answer online and so far I know (may be wrong) that a PDB file by the compiler is generated for obj files while the PDB file by the linker is generated for the binary (exe or dll) and is the one used for debugging.
If that is not true, please explain the difference. Either way, what to do when I am creating a DLL where I have the option to select the output PDB file for the compiler as well as the linker and what to do when I am creating a LIB file where only the compiler generates the PDB files as there is no linking performed.
Background: The libraries/dlls are used by several projects, which then need the PDB files for debugging. In the case of a lib file, there is no ambiguity as there is only one PDB file generated. But in the case of a DLL however, do I need both the PDB files to properly debug or just the one generated by the linker?
I honestly don't know what exactly the .pdb file generated by the compile step is used for - I assume that it's some intermediate information the gets pulled into the final .pdb file by the linker.
However, the bottom line is that for debugging purposes all you need is the .pdb file that is produced by the linker.
Update: A little digging netted this from http://blogs.msdn.com/b/yash/archive/2007/10/12/pdb-files-what-are-they-and-how-to-generate-them.aspx:
What are the two types of .PDB files?
==============================
There are two types of PDB files. One
generated by the compiler named as
VCx0.PDB(e.g. vc80.pdb), and another
the .PDB.
The VCx0.PDB file is generated by the
compiler and it is related to the .OBJ
file. It contains the type information
only.
The .PDB files are
generated by the linker and it is
related with the target executable or
the DLL. This file contains the
complete debug info. When we are
debugging, we need this ‘.pdb’ file
for aligning to the symbols. The
timestamp of the target file and the
PDB should match.
Related
I have an issue where I have a .dll file that is compiled in debug. It statically links with a .lib file, which is also compiled in debug. The source is available for all of them. However when I run the .dll and attach VS to the process it can only step through the .dll's own function but not the ones in the .lib.
In the module view I can see that symbols are loaded for all the modules. How can ensure that .lib has symbols associated with it as well? As I understand because it is linked statically the symbols for it should be generated when compiling the "parent" .dll, is that correct? So is there something I need to do when building the .dll to make sure that ALL functions can be stepped through?
You need to add the location of the pdb file of the LIB you just built for the debugger to find the symbols in the appropriate Tools/Options section (usually the same directory as the output LIB).
Then, you can add the location of the source files in the according Solution Property page :
Then, Visual Studio debugger will find all appropriate information. It will load symbols and be able to jump into the LIB source code when appropriate.
I have a set of 3rd party .LIB file that I am working with and when I compile the project I get a lot of LNK4099 errors. Now I know I can suppress these by using an appropriate linker option, but I was wondering if it is possible to extract/generate the .PDB files from these Libraries.
The PDB (Symbols) File is linked to the Source Code and it is generate at Linker Time. If you need the PDB from some Lib you need ask for it to the provider otherwise you couldn't generate it.
Check this link:
https://msdn.microsoft.com/en-us/library/ms241613.aspx
The problem with LNK4099 refer that compiler doesn't find the PDB file. You can disable it from the project settings, check these links to see how to handled it:
How to remove warning LNK4099: PDB 'lib.pdb' was not found
How to deal with 3rd party c++ libraries LNK4099 Warning in VisualStudio
I'm trying to debug an exe that calls a dll, in Visual Studio. I made sure I had the corresponding pdb in the same path as the dll.
But I cannot get into the functions that the dll is offering.
I get a message that says "xyz.c was not found"
Why am I getting this message?
Does this mean that I can't get into the source code just from a DLL + .PDB?
What about a static library (.lib) built using the /Z7 option?
No, you need to have source code to be able to see the source code.
pdb (or /Z7) contains debug information which is like mapping between executable code and your source code. With pdb VS debugger knows where in source files each instruction is located, but it still needs to have source files to show you the code.
Usually pdb file stores location of source files and VS debugger knows where to find them. If you move src files somewhere else then AFAIK VS will show a popup dialog to browse for .c/.cpp file that it cannot find.
Yes, you need the source code to source debug. The .PDB only contains symbols so you will be able, for example, to view a stack trace or determine the source file name and line number of a crash. Otherwise, you need the source code.
I am generating .dll in visual studio 2010. .lib, .dll, .pdb files are getting generated in output folder.
why .lib (is it static lib?) is genarating along with dll, what is the use of it and
what it contains actually ?
(In linux along with .so it can not have any other files, but why in Windows).
what is this .pdb files, what it contains and how will it be usefull ?
Thanaks in advance :)
.lib alongwith .dll is not static library. It tells the linker that the functions present in lib are to be loaded from the dll. By this, it creates dependency on the dll. Failing to find the dll will cause application to quit (which is checked at the time of start).
It is used in implicit linking of dll.
PDB file is used by debugger to find symbol information.
Why .lib (is it static lib?) is generating along with dll, what is the use of it and what it contains actually ?
No, that .lib is a import library and it is used in implicit linking.
What is this .pdb files, what it contains and how will it be useful ?
PDB file contains Symbol & line information and they are used by debugger to map hex/oct addresses to function names. PDB file is generated when your build your project.
without PDB your program stack trace would look like this
0x00002130
with PDB
0x00002130 yourprogram!function
How do i add .pdb file associated with a lib file?
I am importing a .lib file in a C++ project. When I build it i get an error saying that vc90.pdb does not contains the debug information.
I have the pdb file associated with the library. how can i add it to my current project.
Thanks
We just have the pdb file sitting in the same directory as the .lib file with the same name (ie. foo.lib and foo.pdb) and the compiler appears to pick that up automatically. We don't explicitly point anything at the .pdb files.
I think vc90.pdb is VS2008's fallback if it can't find one with the same name.