gpt4 book ai didi

c++ - 编译器 PDB 文件和链接器 PDB 文件

转载 作者:IT老高 更新时间:2023-10-28 23:00:34 30 4
gpt4 key购买 nike

我对编译器和链接器 PDB 文件分别有什么区别感到困惑(即在 Visual Studio 中,Project Properties > C/C++ > Output Files >程序数据库文件名 vs 项目属性>链接器>调试)。我试图在网上找到答案,到目前为止我知道(可能是错误的)编译器为 obj 文件生成了一个 PDB 文件,而 PDB 文件由链接器为二进制文件(exe 或 dll)生成,用于调试。

如果不是这样,请解释其中的区别。无论哪种方式,当我创建 DLL 时该做什么,我可以选择为编译器和链接器选择输出 PDB 文件,以及何时该做什么我正在创建一个 LIB 文件,其中只有编译器生成 PDB 文件,因为没有执行链接。

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?

最佳答案

老实说,我不知道编译步骤生成的 .pdb 文件到底是做什么用的 - 我认为它是一些中间信息,被链接器拉入最终的 .pdb 文件中。

但是,最重要的是,出于调试目的,您只需要链接器生成的 .pdb 文件。


更新:通过 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.

关于c++ - 编译器 PDB 文件和链接器 PDB 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3796090/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com