Long I am listening the two term that debug mode and release mode ?Can anyone please explain what are those ?
I have heard that depends on gcc and its options -O0 or O2 and -g but not sure exactly about those .Can you please explain with example.

Thanks in advance

4 Years
Discussion Span
Last Post by anirbanengg

I assume you are referring to and GCC-based IDE such as Code::Blocks or something similar here, correct? Basically, they are two different options for generating the executable, which some IDEs provide as a shortcut. They allow you to have two different sets of compiler options to be set up, one for use in development and the other for the final, optimized stand-alone version.

Debug mode by default simply means that it generates code with optimizations disabled (the -O0 option in GCC) and all debugging symbols included (the -g option). This makes it possible to debug the code with the GDB debugger, without having to deal with the various complexities of highly optimized code.

Conversely, Release mode by default has a high level of optimizations in place (-O2 or even -O3, though the latter option includes 'unstable' optimizations and is best avoided), and discards the debugging symbols. It is intended to produce a smaller, faster executable for distribution, at the expense of being able to debug it. Generally speaking, you would only switch to Release mode after you have finished testing and debugging the program, and are ready to ship it to users in binary form.

Edited by Schol-R-LEA


First of all I would like to thank you for your reply .I saw the option in one of such gcc based IDE but I want to know that if I compile a c Code
gcc -c example.c or gcc-o example.o example.c then is it a debug mode because here I did not add any -g option .Is the both mode depends on gcc option or something else is there for determining and working with debug mode and release mode.


First off, just to clear things up a bit: GCC itself does not have any settings called 'debug mode' or 'release mode'. These are purely a construct of the IDE, and how it works will vary from one IDE to another.

Basically, what choosing one mode or another says is, 'I want to use this set of options'. The IDE automagically passes the appropriate set of options to the compiler when it invokes the compiler. Most IDEs give you the option to set the specific options you want in each mode, but give a specific set of defaults that amount to what I told you earlier.

Edited by Schol-R-LEA


I think that I have understood the concept of IDE and how it invokes the compiler with option from your post .But now if I understood the thing properly then I hope that a developer who is developing only in Unix /Linux using vi can not have any mode of compilation.If required they have to explicitly produce the required option and compile .

Please correct me if I am wrong.

Another question is that is it mandatory for any Application to be debugged in debugging mode first.
I have seen people build the code in release mode which was running properly but when they try to debug in debugging mode ,sometimes it consists of error.

You told about debugging Symbol ,I only observed the file size is greater than in debug mode with comparison to the release mode.Can you please explain what debugging symbols are added.

Please help me also about general concept of optimization and for a simple code what are the parmeters of Optimization and how compiler achieves that .

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.