How to: Debug a Release Build

You can debug a release build.

To enable debugging of a release build, change the following release build options

  1. Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.

  2. Enable /Z7 or /Zi.


  4. Select /DEBUG:Yes.

  5. Select /OPT:REF.

  6. Select /OPT:ICF.

You can now debug your release build application. To find the problem, step through the code (or of using Just-In-Time debugging) until you find where the failure occurs, and then determine the incorrect parameters or code.

If a program works in a debug build, but fails in a release build, it is likely that one of the compiler optimizations is exposing a defect in your source code. To isolate the problem, you should disable selected optimizations for each source code file, until you locate the file and the optimization that is causing the problem. For example, you may want to divide the files into two groups, disable optimization on one group, and continue dividing until you isolate the problem to a single file.

You may want to use /RTC to try to expose such bugs in your debug builds.

See Optimizing Your Code for more information.

Community Additions