Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] How to build Release with debug info (MinGW)
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to build Release with debug info (MinGW)

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 25.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    Uwe Kindler
    wrote on last edited by
    #1

    Hi,

    I need to debug a release build of my application and therefore need to add debug info to the release build. I added the following lines to my pro file:

    QMAKE_CXXFLAGS_RELEASE *= -g
    QMAKE_CFLAGS_RELEASE *= -g

    If I attach QtCreator to the running application, the source files view does not list any source file of my application but lists some source files of some libraries (dlls) that I have built without qmake and that I have linked to my application. I can not start debug session for the release build in eclipse and the size of the generated EXE and DLL files is much smaller than the ones generated during debug built. So I assume that there are no debug symbols in the EXE and DLL files although I have added the -g option to my release build. Debugging the debug version of my application is no problem - so this is no issue of missing source files or invalid paths.

    If I compile the release build I can see the following compiler output for each source file:

    g++ -c -O2 -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"C:....

    So the flag -g is properly passed to the compiler. If I remove the -g flag (remove QMAKE_CXXFLAGS_RELEASE *= -g
    QMAKE_CFLAGS_RELEASE *= -g) the size of the application file and DLLs does not change. So obviously the -g option does not add any debug information to the release build.

    So why does my release build does not contain debug symbols and how should I change my pro file to generate a release build with debug info?

    Thank you,

    Uwe

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sabrog
      wrote on last edited by
      #2

      May be problem in "strip" tool, try unset this flags:

      @QMAKE_STRIP=
      @

      QT - Apple QuickTime
      Qt - Nokia's Qt Development Frameworks
      Apple is a competitor of Nokia, so QT != Qt

      1 Reply Last reply
      0
      • U Offline
        U Offline
        Uwe Kindler
        wrote on last edited by
        #3

        Thank you for your answer. Too bad that this does not solve the issue.

        1 Reply Last reply
        0
        • U Offline
          U Offline
          Uwe Kindler
          wrote on last edited by
          #4

          Ok, I solved it myself.

          The file qt\mkspecs\default\qmake.conf defines the following linker flags:

          QMAKE_LFLAGS_RELEASE = -Wl,-s

          The linker flag -s means: Omit all symbol information from the output file.

          So it is the linker that removes all debug information from release build. So if you want to build a release version with debug info you need to define the following in your pro file:

          QMAKE_CXXFLAGS_RELEASE += -g
          QMAKE_CFLAGS_RELEASE += -g
          QMAKE_LFLAGS_RELEASE =

          Now I can properly debug the release build of my application.

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved