Search code examples
macosqtqmakedebug-symbolsdebug-information

Build Qt application on MacOS with debug symbols


How could I build an application for macOS written using Qt framework in Release mode with debug symbols information ?

I have tried what is suggested in Qt Doc:

# debug symbols
QMAKE_CFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO
QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO
QMAKE_OBJECTIVE_CFLAGS_RELEASE += $$QMAKE_OBJECTIVE_CFLAGS_RELEASE_WITH_DEBUGINFO
QMAKE_LFLAGS_RELEASE += $$QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO

But I get same output when I run nm command.

What am I missing?

Thanks in advance


Solution

  • You can use built-in CONFIG flags to create separate debugging symbols:

    CONFIG+=force_debug_info CONFIG+=separate_debug_info

    (possibly add CONFIG+=release CONFIG-=debug CONFIG-=debug_and_release to make extra-sure to get a pure release + debug info build).

    Note that this is what the “Profile” build in Qt Creator does by default.