How do i add .pdb file associated with a lib file? - c++

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.

Related

How to change the location of .pdb files for static libraries?

Now I found out I can change the .pdb file location for C++ executable projects in Linking -> Debugger in the project settings.
How can I change the location for static library projects? As they do not have the Linker menu.
I tried changing C/C++ -> Output files -> Program Database File Name, but without luck. They are still added to the same directory as the compiled executable.
After changing the Program Database File Name, pdb will be added to the specified directory. In addition, if the lib file directories are not changed, another pdb file will also be added aside the lib. This may be why you think it was unsuccessful, but in fact it has been done.

Injected DLL can't use Symbols pdb unless it's in the same directory as build

I have an issue where I'm trying to selectively distribute my pdb(symbol) file so I can have users give me more detailed crash reports.
So... my DLL is injected into another exe (in another folder). And from everything I've tested, my PDB file has to be located in the exact same directory on the users machine that it is on my machine for it to be found correctly.
IE... When I build I place the PDB in C:\PDB\Mypdb.pdb
If the user creates the exact folder and places the pdb there, the injected dll will show him line numbers on crash. However, if he places the mypdb.pdb with the dll, or with the target of the injection, they receive nothing in terms of symbols.
Any ideas on how I can force my DLL to use a symbols file at a custimizable location?
This is because by default the linker uses an absolute path to the location where it generates PDB file and stores it in the DLL itself. You can change the path to the PDB file by passing the /PDBALTPATH option and a relative path to the linker.

What is .lib file contain while generating DLL

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

Why does Visual Studio generate these additional files?

In the output directory where Visual Studio places the compiled executable, there are three additional files of the types *.exp, *.lib, .pdb. I do not need those files and I would like to prevent the compiler from creating them.
This is how my build output directory looks like. I only need the *.exe file.
What are these additional files for? How can I disable that they are generated? If they are needed for the build process, is there a way to automatically remove them after the executable is created?
I am using Visual Studio 2012. If you need additional details, please comment.
EXP and LIB files But I don't want that .lib or .exp file for my COM library! . You could probably set the location of these files in the "Intermediate Output" setting and not have them in your release folder
I'm assuming you are looking to have only the dll and exe files in your final release directory and the *.exp, *.lib, .pdb files left in your intermediate directory as to not clutter the directory you are working in.
Visual Studio 2017
Open properties (Right click on the project in the solution explorer):
change settings as shown:
Import Library will define where the .lib and .exp files are created.
Generate Program Database File defines where the .pdb file is created.
Debug information format -- None will prevent pdb file from being created. Select this option for Release builds.
There some functions inside declared with as __declspec(dllexport).
It means that they are exported and linker thinks that there is a need to link with this dynamic library (no matter it is exe or dll - in general the structure is the same) and creates *.lib and *.exp file

Compiler PDB file and the Linker PDB file

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.