Running Debug vs releases builds in Qt

Can anyone explain, other than the debugging symbols built into the debug assembly, if there is any other difference. Further, I am very curious to find out how they differ when executing binary code. What mechanisms are used to use debugging symbols in the debug assembly show errors.

+4
source share
2 answers

Compiling as debugging in qt sets the -DQT_NO_DEBUG flag for one thing in a compiler call, which is used in many qt libraries. As Jimmy has already pointed out, the main difference in performance comes from this source. One extreme example is the use of a debug version of STL containers that can be used to check boundaries. If this is used in your code in debug mode, things can take a lot of time (Qt does not use this, but introduces similar checks in its libraries).

In addition, optimization flags are usually changed. For release, -O2 is selected for release and is not optimized for debugging.

Another important thing in debug builds is that you can use it to run various things in a pro file, such as adding definitions, changing a target, or compiling with respect to another set of libraries:

CONFIG(debug, debug|release) { message("Debug") DESTDIR = $$DESTDIR-debug CONFIG += debug DEFINES += DEBUG TARGET = $$TARGET-debug }else{ message("Release") DEFINES += QT_NO_DEBUG_OUTPUT DESTDIR = $$DESTDIR-release TARGET = $$TARGET-release } 

If you are interested in more details, see the qmake configuration files. Linux Ubuntu: / usr / share / qt4 / mkspecs / common / g ++. Conf / usr / share / qt4 / mkspecs / common / linux.conf and client dependent conf

+3
source

The exact definition and behavior of the "release build" compared to the "debug build" depends on the build system and the compiler you use. Some common release features are built compared to debug builds:

  • Debug builds usually generate debug information, but a release does not. There are some hybrids, though, like a build release with separate debugging information.
  • Assertions are not evaluated (assert (p = getFoo ()), will not assign anything - and not assert). Therefore, expressions with side effects inside statements are a bad idea.
  • Optimization parameters usually vary (no or few optimizations in debug builds)
  • Debug output can be suppressed
  • Any library developer can additionally implement different behavior depending on, for example, the NDEBUG preprocessor macro
+1
source

All Articles