visual-studio 使用 Visual Studio 在发布二进制文件中生成符号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/865546/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Generating Symbols in release binaries with Visual Studio
提问by Justin
Update: I posted a comment on John Robbinsblog about the. He wrote a response here:
更新:我在John Robbins博客上发表了关于 . 他在这里写了一个回应:
http://www.wintellect.com/CS/blogs/jrobbins/archive/2009/06/19/do-pdb-files-affect-performance.aspx
http://www.wintellect.com/CS/blogs/jrobbins/archive/2009/06/19/do-pdb-files-affect-performance.aspx
The project I am working on does not build symbols for its release binaries, and I would like to change this.
我正在处理的项目没有为其发布二进制文件构建符号,我想改变这一点。
Some info:
一些信息:
- Mostly C++ code base, some C#.
- Compiled under VS2k5, will be moving to VS2k8 Team System.
- Time critical software.
- Must have optimizations enabled.
- Source code is provided to customer so full symbols are fine.
- 主要是 C++ 代码库,一些 C#。
- 在VS2k5下编译,将迁移到VS2k8 Team System。
- 时间关键的软件。
- 必须启用优化。
- 源代码提供给客户,所以完整的符号很好。
What are the best command line switches to generate what I need, and what, if any, performance hits am I going to take?
什么是最好的命令行开关来生成我需要的东西,如果有的话,我将采取什么性能影响?
Also, are there any "Gotchas" to be aware of?
另外,是否有任何“陷阱”需要注意?
采纳答案by Justin
Update: I posted a comment on John Robbinsblog about the. He wrote a response here:
更新:我在John Robbins博客上发表了关于 . 他在这里写了一个回应:
http://www.wintellect.com/CS/blogs/jrobbins/archive/2009/06/19/do-pdb-files-affect-performance.aspx
http://www.wintellect.com/CS/blogs/jrobbins/archive/2009/06/19/do-pdb-files-affect-performance.aspx
I found the following link on microsofts website: Generating and Deploying Debug Symbols with Microsoft Visual C++ 6.0
我在 microsofts 网站上找到了以下链接: Generating and Deploying Debug Symbols with Microsoft Visual C++ 6.0
This link pertains to Visual C++ 6, but I am assuming these instructions are the same for Visual C++ 8(2005) and 9(2008).
此链接适用于 Visual C++ 6,但我假设这些说明对于 Visual C++ 8(2005) 和 9(2008) 是相同的。
The information it gives is very similar to the link provided by TheBlack but more in-depth.
它提供的信息与 TheBlack 提供的链接非常相似,但更深入。
回答by TheBlack
回答by DougN
Generating debug symbols (ie PDB files) is just creating an external file that a debugger can reference when looking at your code in memory. It doesn't affect the code that the compiler or linker generate (sort of like generating a .MAP file).
生成调试符号(即 PDB 文件)只是创建一个外部文件,调试器在查看内存中的代码时可以引用该文件。它不会影响编译器或链接器生成的代码(有点像生成 .MAP 文件)。
Now if you're talking about defining _DEBUG in a release build, that's a whole different question.
现在,如果您正在谈论在发布版本中定义 _DEBUG,那是一个完全不同的问题。
回答by MikeOnline
The /Ziswitch in Visual C++ will create a PDB, but this setting also implies additional settings that will make the DLL or EXE larger. Specifically, /Ziimplies /DEBUG, which implies /INCREMENTAL, /OPT:NOREFand /OPT:NOICF. The last three make the compiled DLL or EXE bigger, but they can be overridden by specifying /OPT:REFand /OPT:ICFin addition to /Zi. There is no need to override /INCREMENTAL, as /OPT:REFand/or /OPT:ICFwill ensure a full, non-incremental link.
Visual C++ 中的/Zi开关将创建一个 PDB,但此设置也意味着其他设置将使 DLL 或 EXE 更大。具体来说,/Zi意味着/DEBUG,这意味着/INCREMENTAL、/OPT:NOREF和/OPT:NOICF。最后三个使编译后的 DLL 或 EXE 更大,但它们可以通过指定/OPT:REF和/OPT:ICF除了/Zi. 无需覆盖/INCREMENTAL,因为/OPT:REF和/或/OPT:ICF将确保完整的非增量链接。
回答by Macke
I don't know the command line, but you need to set debug symbols both in c++ compiler config (program database) and the linker (generate debug info) in the IDE.
我不知道命令行,但是您需要在 IDE 中的 c++ 编译器配置(程序数据库)和链接器(生成调试信息)中设置调试符号。
If you find the settings in the project, you can use help to see which command-lines they refer to.
如果您在项目中找到设置,您可以使用帮助查看它们引用的命令行。

