如何使用外部pdb进行链接? [英] How to link using an external pdb?

查看:178
本文介绍了如何使用外部pdb进行链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VS2012中,我静态链接到预编译的.lib,并且还需要使用该lib的.pdb文件进行调试. 如何告诉链接器它应该使用该外部pdb文件?

In VS2012, I'm statically linking with a precompiled .lib, and need to also use that lib's .pdb file for debugging. How can I tell the linker that it should use that external pdb file?

推荐答案

如果您使用/ZI或/Zi创建了静态库(请参见C/C ++的项目设置->常规->调试信息格式),然后输入$创建(IntDir)vc $(PlatformToolsetVersion).pdb文件.路径由/Fd定义.

If you created the static lib with /ZI or /Zi (see project settings for C/C++ -> General -> Debug Information Format), then the $(IntDir)vc$(PlatformToolsetVersion).pdb file is created. The path is defined by /Fd.

使用静态库的链接程序通常也引用此pdb文件.如果您将可执行文件与静态库链接,而链接器找不到pdb文件,您应该会收到这样的错误

A linker that uses the static library usually also refers to this pdb file. If you link an executable with the static lib and the linker can't find the pdb file you should get the error like this

LNK4099:找不到'foo.lib(foo.obj)PDB'vc1xx.pdb'

LNK4099: PDB 'vc1xx.pdb' was not found with 'foo.lib(foo.obj)

因此,您想要的是默认设置.您可以打开详细链接以查看符号发生了什么情况.

So what you want is the default. You may turn on verbose linking to see what happens to your symbols.

Microsoft始终随附带有其静态库的PDB文件,其静态库的名称与静态库相同.所以您找到一个libcmt.lib和一个libcmt.pdb

Microsoft always ships a PDB file with their static libraries named the same way like the static lib. So you find a libcmt.lib and a libcmt.pdb

这篇关于如何使用外部pdb进行链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆