问题描述
我必须调试一个c ++项目,但是由于一个依赖关系不能在调试模式下进行编译,到目前为止我还没有解决这个问题,我想尝试在发布模式下调试该项目。目前,应用程序由于空指针而崩溃,但是我没有导致错误的代码。由于断点显然在释放模式下被忽略,我想知道什么是找到错误的最佳方式。
在VS中,右键单击您的项目,选择属性。
-
单击C / C ++节点。将调试信息格式设置为C7兼容(/ Z7)或程序数据库(/ Zi)。
-
展开链接器,然后单击常规节点。设置启用增量链接为否(/ INCREMENTAL:否)。
-
选择调试节点。将生成调试信息设置为是(/ DEBUG)。
-
选择优化节点。将参考设置为Yes(/ OPT:REF)。
直接从Microsoft的文档中剥离:
我一直都这样做,几乎从来没有在调试模式下调试。如你所知,发布版本中发生的许多错误可能不会发生在调试版本中(几乎肯定是调用UB引起的错误)。
另外,我在一个使用大量图像处理的项目上工作,并执行大量图像的压缩/解压缩。使用缓慢的调试版本是不切实际的。
I have to debug a c++ project, but as one dependency doesn't compile in debug mode and I haven't been able to fix that issue so far, I'd like to try to debug the project in release mode.
Currently the application crashes due to a null pointer, but I haven't the code that's causing the error. As break points apparently are ignored in release-mode, I'd like to know what's the best way find the error.
In VS, right click your project, chose "Properties".
Click the C/C++ node. Set Debug Information Format to C7 compatible (/Z7) or Program Database (/Zi).
Expand Linker and click the General node. Set Enable Incremental Linking to No (/INCREMENTAL:NO).
Select the Debugging node. Set Generate Debug Info to Yes (/DEBUG).
Select the Optimization node. Set References to Yes (/OPT:REF).
That's ripped directly from Microsoft's documentation:
I do this all of the time and pretty much never debug in debug mode anymore. As you know, many errors that occur in a release build may not occur in a debug build (almost certainly the errors that arise from invoking UB).
Also, I work on a project which uses a ton of image processing and performs a lot of compression/decompression of large images. Using a slow debug build is simply impractical.
这篇关于如何在发布模式下进行调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!