Build Qt in "Release with Debug Info" mode?

Ashika Umanga Umagiliya picture Ashika Umanga Umagiliya · Aug 9, 2011 · Viewed 22.9k times · Source

Is there a way to build Qt in "Release with Debug info" mode ? My application crashes only in "release" mode (works fine in Debug mode) and seems the issue comes from Qt (may be a bug in Qt).So I want to see the debug info of Qt.

Qt docs has "debug" , "release" but not "release with debug" mode.

[Upate]

My application works fine with Mingw 32bit Release/Debug and VSC++ Compiler 64bit Debug.

Only crashes on VSC++ 64Bit Release

Any tips ?

Answer

milianw picture milianw · Feb 29, 2016

Old question, I know. But nowadays, you can simply use

CONFIG += force_debug_info

to get debug symbols even in release mode. When you use QMake via the command line, I usually do this to get a release build with debug info:

qmake CONFIG+=release CONFIG+=force_debug_info path/to/sources

this will enable below conditions of Qt5/mkspecs/features/default_post.prf:

force_debug_info|debug: CONFIG += debug_info
force_debug_info {
    QMAKE_CFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO
    QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO
    QMAKE_LFLAGS_RELEASE = $$QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO
}

which would even work for Qt 4.x but we would need to manually append above conditions into default_post.prf for Qt 4.x