Difference between Debug and Release versions?

Answer Posted / varun k. singh

Q: Why does program work in debug mode, but fail in release mode?

The VC++ IDE offers the possibility to define configurations which include a set of project settings (like compiler / linker options, output directories etc.) When a project is created using AppWizard, you get two default configurations: "Win32 Debug" and "Win32 Release". These are just convenient starter configurations with several preset options which are suitable for typical debug builds or release builds respectively, but you are by no means restricted to those settings. Actually, you can modify those configurations, delete them, or create new ones. Now let's see what the two default configurations typically include and what distinguishes them:

Win32 Debug:
Subdirectory 'Debug' used for temporary and output files
Preprocessor symbol _DEBUG defined
Debug version of the runtime libraries is used
All compiler optimizations turned off
Generate debug info

Win32 Release:
Subdirectory 'Release' used for temporary and output files
Preprocessor symbol NDEBUG defined
Release version of the runtime libraries is used
Various compiler optimizations turned on
Generate no debug info

There are a few other differences, but these are the most important ones. Now, what's the first implication of all this? That, as opposed to a common misunderstanding, you can debug a release build. Just go to 'Project -> Settings', choose the Win32 Release configuration, tab 'C/C++', 'General' and set 'Debug Info' to 'Program Database'. Then go to the tab 'Linker', and turn on 'Generate Debug Info'. If you rebuild your project now, you will be able to run it in the debugger. Regardless of whether your program crashes or just doesn't behave as expected, running it in the debugger will show you why. Note however, that due to optimizations turned on in the release build, the instruction pointer will sometimes be off by a few code lines, or even skip lines altogether (as the optimizer didn't generate code for them). This shouldn't be a concern, if it is, turn off optimizations.

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

2.create for 10 batch: Employee_Number Employee_name Employee_Dateofjoining Employee_address Employee_salary 1.select the employee name who deriving more than 10 thousand salary and joined before august 08. use structure and pointers

1810


What does mfc stand for?

960


How do I create a dialog box in mfc?

610


What is mfc class hierarchy?

616


how to repaint when working with horizontal scroll bar

1547






plzz tell me what we can do and dont in tally ERP & sap business one?

1879


How to handle dynamic menus in mfc? What happens when client calls cocreateinstance?

692


What is the difference between Struts and JSF? Pls list some most suitable differences.

2844


what is the meaning of constant FILE EXCEEDS LENGTH LIMIT while loading from ps file to vsam in the jcl?

3342


Do you have an idea about MFC?

914


what message is sent to an application when the user presses the primary button?

1385


what is functioning of DIalodDataXchange ..?

1191


List out the basic features of MFC.

13680


I want recent paper pattern for HP company?

1786