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. Debug_and_release: how to get rid of autogenerated debug/release folders
Qt 6.11 is out! See what's new in the release blog

Debug_and_release: how to get rid of autogenerated debug/release folders

Scheduled Pinned Locked Moved General and Desktop
24 Posts 7 Posters 14.7k 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.
  • S Offline
    S Offline
    sayezz
    wrote on last edited by
    #7

    is there a possibillity to achieve this with only one .pro file?

    I do not want to have several .pro files. i would like that the whole configuration stays in one file, so that a person have only to edit one file.

    this bevhaivior with the generated folders is only then, when i use the "debug_and_release" flag in CONFIG +=

    Maybe i just shouldnt use this flag ?

    Thanks

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JamesBrown147
      wrote on last edited by
      #8

      Hi there!

      I have the same problem here. Did you find a solution?

      My qmake also generates die release/debug folders and it seems that I can't do nothing about it.

      Thanks!

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JamesBrown147
        wrote on last edited by
        #9

        oh, I just found the solution!

        If you set the MOC_DIR variable, then qmake does not generate the folders. My code looks like this now:

        DESTDIR = bin/debug
        OBJECTS_DIR = bin/debug
        MOC_DIR = bin/debug

        1 Reply Last reply
        0
        • M Offline
          M Offline
          miroslav
          wrote on last edited by
          #10

          @JamesBrown147: Watch out, these directories will now be used for debug and release builds, unless you added logic around it.

          Mirko Boehm | mirko@kde.org | KDE e.V.
          FSFE Fellow
          Qt Certified Specialist

          1 Reply Last reply
          0
          • X Offline
            X Offline
            xenotrax
            wrote on last edited by
            #11

            I got the same problem. :-( (error only on Windows no problems with Fedora )

            QDir::currentPath() is
            C:\Qt\ding\build-poppi-Desktop_Qt_5_3_MSVC2013_64bit-Debug

            but the real exe is in
            C:\Qt\ding\build-poppi-Desktop_Qt_5_3_MSVC2013_64bit-Debug\debug

            automatic created folders are
            C:\Qt\ding\build-poppi-Desktop_Qt_5_3_MSVC2013_64bit-Debug\debug
            C:\Qt\ding\build-poppi-Desktop_Qt_5_3_MSVC2013_64bit-Debug\release

            C:\Qt\ding\build-poppi-Desktop_Qt_5_3_MSVC2013_64bit-Release\debug
            C:\Qt\ding\build-poppi-Desktop_Qt_5_3_MSVC2013_64bit-Release\release

            1 Reply Last reply
            0
            • D Offline
              D Offline
              DanWatkins
              wrote on last edited by DanWatkins
              #12
              This post is deleted!
              1 Reply Last reply
              0
              • M Offline
                M Offline
                Mozi
                wrote on last edited by Mozi
                #13

                @sayezz @xenotrax
                Hi! If you are using Windows, please see this: c++ - Qt Creator creates both a debug and a release folder inside the designated debug folder - Stack Overflow

                CONFIG -= debug_and_release debug_and_release_target
                

                Putting this line into the .pro file solves my problem.

                You can add a test about the platform to confirm that only Qt (qmake) on Windows will change this configuration, like this:

                win32 {
                    message($$CONFIG)
                    CONFIG -= debug_and_release debug_and_release_target
                    message($$CONFIG)
                }
                

                edit on 2/8/2020:

                Add CONFIG -= debug_and_release is enough.

                aha_1980A M 2 Replies Last reply
                2
                • M Mozi

                  @sayezz @xenotrax
                  Hi! If you are using Windows, please see this: c++ - Qt Creator creates both a debug and a release folder inside the designated debug folder - Stack Overflow

                  CONFIG -= debug_and_release debug_and_release_target
                  

                  Putting this line into the .pro file solves my problem.

                  You can add a test about the platform to confirm that only Qt (qmake) on Windows will change this configuration, like this:

                  win32 {
                      message($$CONFIG)
                      CONFIG -= debug_and_release debug_and_release_target
                      message($$CONFIG)
                  }
                  

                  edit on 2/8/2020:

                  Add CONFIG -= debug_and_release is enough.

                  aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on last edited by
                  #14

                  Hi @Mozi,

                  debug_and_release is only set on Windows, so no need for a scope.

                  And you need to make sure to use shadow-building if you disable that! The reason this variable is set by default is that on Windows it's impossible to mix debug and release objects.

                  If that is ok for you, you can savely disable that variable (like I do), as it makes the whole handling more easy.

                  Regards

                  Qt has to stay free or it will die.

                  M 2 Replies Last reply
                  3
                  • aha_1980A aha_1980

                    Hi @Mozi,

                    debug_and_release is only set on Windows, so no need for a scope.

                    And you need to make sure to use shadow-building if you disable that! The reason this variable is set by default is that on Windows it's impossible to mix debug and release objects.

                    If that is ok for you, you can savely disable that variable (like I do), as it makes the whole handling more easy.

                    Regards

                    M Offline
                    M Offline
                    Mozi
                    wrote on last edited by
                    #15

                    Hi @aha_1980 ,
                    Thanks for your reply.
                    I noticed that the Shadow build feature is enabled by default, so I can remove debug_and_release safely.
                    https://doc.qt.io/qtcreator/creator-build-settings.html#qmake-build-configuration

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      Mozi
                      wrote on last edited by
                      #16
                      This post is deleted!
                      1 Reply Last reply
                      0
                      • aha_1980A aha_1980

                        Hi @Mozi,

                        debug_and_release is only set on Windows, so no need for a scope.

                        And you need to make sure to use shadow-building if you disable that! The reason this variable is set by default is that on Windows it's impossible to mix debug and release objects.

                        If that is ok for you, you can savely disable that variable (like I do), as it makes the whole handling more easy.

                        Regards

                        M Offline
                        M Offline
                        Mozi
                        wrote on last edited by
                        #17

                        And, @aha_1980 ,

                        on Windows it's impossible to mix debug and release objects.

                        I cannot get the point, could you please explain a little more?
                        Thanks.

                        aha_1980A 1 Reply Last reply
                        0
                        • M Mozi

                          And, @aha_1980 ,

                          on Windows it's impossible to mix debug and release objects.

                          I cannot get the point, could you please explain a little more?
                          Thanks.

                          aha_1980A Offline
                          aha_1980A Offline
                          aha_1980
                          Lifetime Qt Champion
                          wrote on last edited by
                          #18

                          @Mozi The MSVC compiler uses different runtime libs for debug and release builds. Mixing them, e.g. using a debug DLL with a release program may crash.

                          Things are different for the MinGW compiler though, which is the reason Qt 5.14 is compiled without debug_and_release on this platform.

                          Regards

                          Qt has to stay free or it will die.

                          1 Reply Last reply
                          4
                          • M Offline
                            M Offline
                            Mozi
                            wrote on last edited by
                            #19

                            Hi @aha_1980 .
                            There are some new problems but it may be off-topic. Thanks for your previous reply.

                            When debug_and_release was removed, the flag build_pass was removed too. And I discovered that build_pass will affect the windeployqt target's behavior. Here is a code snippet of windeployqt.prf from Qt 5.14.1.

                            # Extra target for running windeployqt
                            qtPrepareTool(QMAKE_WINDEPLOYQT, windeployqt)
                            build_pass {
                                #...
                                windeployqt.target = windeployqt
                                windeployqt.commands = $$QMAKE_WINDEPLOYQT $$WINDEPLOYQT_OPTIONS -list target $$WINDEPLOYQT_TARGET > $$WINDEPLOYQT_OUTPUT
                                
                                windeployqt_clean.commands = if exist $$WINDEPLOYQT_OUTPUT for /f %i in ($$WINDEPLOYQT_OUTPUT) do $$QMAKE_DEL_FILE %~fi && $$QMAKE_DEL_DIR %~pi
                                #...
                            } else {
                                windeployqt.CONFIG += recursive
                                windeployqt_clean.CONFIG += recursive
                            }
                            QMAKE_EXTRA_TARGETS += windeployqt windeployqt_clean
                            

                            The problem, makes me confused, is the relationship between the CONFIGs mentioned above. If there is no debug_and_release flag, windeployqt will do nothing. I know I can add build_pass to CONFIG manually, but... What's the original purpose of this design?

                            Moreover, I found that if I use default CONFIG (contains debug_and_release and debug_and_release_target) with windeployqt, make windeployqt will complain about no release target exists (under debug mode) or no debug target exists (under release mode), and the process will stop. Is this by design? And what's the reason?

                            Thanks!
                            Regards

                            aha_1980A M 2 Replies Last reply
                            0
                            • M Mozi

                              Hi @aha_1980 .
                              There are some new problems but it may be off-topic. Thanks for your previous reply.

                              When debug_and_release was removed, the flag build_pass was removed too. And I discovered that build_pass will affect the windeployqt target's behavior. Here is a code snippet of windeployqt.prf from Qt 5.14.1.

                              # Extra target for running windeployqt
                              qtPrepareTool(QMAKE_WINDEPLOYQT, windeployqt)
                              build_pass {
                                  #...
                                  windeployqt.target = windeployqt
                                  windeployqt.commands = $$QMAKE_WINDEPLOYQT $$WINDEPLOYQT_OPTIONS -list target $$WINDEPLOYQT_TARGET > $$WINDEPLOYQT_OUTPUT
                                  
                                  windeployqt_clean.commands = if exist $$WINDEPLOYQT_OUTPUT for /f %i in ($$WINDEPLOYQT_OUTPUT) do $$QMAKE_DEL_FILE %~fi && $$QMAKE_DEL_DIR %~pi
                                  #...
                              } else {
                                  windeployqt.CONFIG += recursive
                                  windeployqt_clean.CONFIG += recursive
                              }
                              QMAKE_EXTRA_TARGETS += windeployqt windeployqt_clean
                              

                              The problem, makes me confused, is the relationship between the CONFIGs mentioned above. If there is no debug_and_release flag, windeployqt will do nothing. I know I can add build_pass to CONFIG manually, but... What's the original purpose of this design?

                              Moreover, I found that if I use default CONFIG (contains debug_and_release and debug_and_release_target) with windeployqt, make windeployqt will complain about no release target exists (under debug mode) or no debug target exists (under release mode), and the process will stop. Is this by design? And what's the reason?

                              Thanks!
                              Regards

                              aha_1980A Offline
                              aha_1980A Offline
                              aha_1980
                              Lifetime Qt Champion
                              wrote on last edited by aha_1980
                              #20

                              Hi @Mozi,

                              for which compiler is that? MSVC or MinGW?

                              Anyway, I can't answer these questions, I'm not that deep in qmake. You might want to ask these questions on the Qt Interest mailing list, where more developers might be able to help you.

                              Regards

                              Qt has to stay free or it will die.

                              M 1 Reply Last reply
                              0
                              • aha_1980A aha_1980

                                Hi @Mozi,

                                for which compiler is that? MSVC or MinGW?

                                Anyway, I can't answer these questions, I'm not that deep in qmake. You might want to ask these questions on the Qt Interest mailing list, where more developers might be able to help you.

                                Regards

                                M Offline
                                M Offline
                                Mozi
                                wrote on last edited by Mozi
                                #21

                                Hi @aha_1980 .
                                I'm using MSVC2017. And thanks for your suggestion :-)

                                Regards

                                1 Reply Last reply
                                1
                                • M Mozi

                                  Hi @aha_1980 .
                                  There are some new problems but it may be off-topic. Thanks for your previous reply.

                                  When debug_and_release was removed, the flag build_pass was removed too. And I discovered that build_pass will affect the windeployqt target's behavior. Here is a code snippet of windeployqt.prf from Qt 5.14.1.

                                  # Extra target for running windeployqt
                                  qtPrepareTool(QMAKE_WINDEPLOYQT, windeployqt)
                                  build_pass {
                                      #...
                                      windeployqt.target = windeployqt
                                      windeployqt.commands = $$QMAKE_WINDEPLOYQT $$WINDEPLOYQT_OPTIONS -list target $$WINDEPLOYQT_TARGET > $$WINDEPLOYQT_OUTPUT
                                      
                                      windeployqt_clean.commands = if exist $$WINDEPLOYQT_OUTPUT for /f %i in ($$WINDEPLOYQT_OUTPUT) do $$QMAKE_DEL_FILE %~fi && $$QMAKE_DEL_DIR %~pi
                                      #...
                                  } else {
                                      windeployqt.CONFIG += recursive
                                      windeployqt_clean.CONFIG += recursive
                                  }
                                  QMAKE_EXTRA_TARGETS += windeployqt windeployqt_clean
                                  

                                  The problem, makes me confused, is the relationship between the CONFIGs mentioned above. If there is no debug_and_release flag, windeployqt will do nothing. I know I can add build_pass to CONFIG manually, but... What's the original purpose of this design?

                                  Moreover, I found that if I use default CONFIG (contains debug_and_release and debug_and_release_target) with windeployqt, make windeployqt will complain about no release target exists (under debug mode) or no debug target exists (under release mode), and the process will stop. Is this by design? And what's the reason?

                                  Thanks!
                                  Regards

                                  M Offline
                                  M Offline
                                  Mozi
                                  wrote on last edited by
                                  #22

                                  The new discovery record:
                                  If I add build_pass, Qt Creator will complain about the Makefile after qmake:

                                  Could not parse Makefile. The build in \path\to\the\build will be overwritten.
                                  

                                  Well, I don't know if it's harmful to manually add this argument by the developer.
                                  It's not well-documented...

                                  The only build_pass phrase in the page (https://doc.qt.io/qt-5/qmake-variable-reference.html):

                                  During the latter passes, **build_pass** and the respective debug or release option is appended to CONFIG. This makes it possible to perform build-specific tasks. For example:
                                  
                                  build_pass:CONFIG(debug, debug|release) {
                                      unix: TARGET = $$join(TARGET,,,_debug)
                                      else: TARGET = $$join(TARGET,,,d)
                                  }
                                  
                                  M 1 Reply Last reply
                                  0
                                  • M Mozi

                                    @sayezz @xenotrax
                                    Hi! If you are using Windows, please see this: c++ - Qt Creator creates both a debug and a release folder inside the designated debug folder - Stack Overflow

                                    CONFIG -= debug_and_release debug_and_release_target
                                    

                                    Putting this line into the .pro file solves my problem.

                                    You can add a test about the platform to confirm that only Qt (qmake) on Windows will change this configuration, like this:

                                    win32 {
                                        message($$CONFIG)
                                        CONFIG -= debug_and_release debug_and_release_target
                                        message($$CONFIG)
                                    }
                                    

                                    edit on 2/8/2020:

                                    Add CONFIG -= debug_and_release is enough.

                                    M Offline
                                    M Offline
                                    Mozi
                                    wrote on last edited by Mozi
                                    #23

                                    Ummm, I think we should NOT remove the debug_and_release and debug_and_release_target flags, whether we need multiple build configurations or not.


                                    debug_and_release & Shadow build

                                    In VS (VC++), the output folders (Debug and Release) are in the same directory as the source file (The root of the source folder).
                                    In Qt, if the debug_and_release flag exists, the structure of the output folder is very similar to VS.

                                    /
                                    +---project.pro
                                    +---main.cpp
                                    +---debug
                                    |       *.obj
                                    |       moc_*.cpp
                                    |       target.exe
                                    |
                                    +---release
                                            *.obj
                                            moc_*.cpp
                                            target.exe
                                    

                                    Shadow build wants to make the source tree clean and place all generated files in the build directory. For macOS and Linux, it works well. However, for Windows, these files will be placed in nested folders (extra Debug and Release folders) because of the debug_and_release flag. I know the structure looks weird, but I think we should keep it as it is and avoid potential impacts (for example, #19 of this thread).

                                    Ref:

                                    • https://stackoverflow.com/questions/35999940/qt-after-specifying-output-directory-it-still-create-debug-and-release-folders-i#answer-36000284
                                    Term Meaning
                                    Shadow build Shadow building means building a project in a separate directory, the build directory. The build directory is different from the source directory. One of the benefits of shadow building is that it keeps your source directory clean, which makes it faster to switch between build configurations. Therefore, shadow building is the best practice if you need many build configurations for a single set of source files.

                                    from: https://doc.qt.io/qtcreator/creator-glossary.html#glossary-shadow-build


                                    debug_and_release_target

                                    The difference between the Makefile.Release file with (red) and without (green) the debug_and_release_target flag:

                                    ...
                                    - DESTDIR        = release\ #avoid trailing-slash linebreak
                                    + DESTDIR        =  #avoid trailing-slash linebreak
                                    - DESTDIR_TARGET = release\project.exe
                                    + DESTDIR_TARGET = project.exe
                                    ...
                                    first: all
                                    - all: Makefile.Release  release\project.exe
                                    + all: Makefile.Release  project.exe
                                    ...
                                    - release\project.exe: ...
                                    + project.exe: ...
                                    ...
                                    

                                    Without debug_and_release_target, if debug_and_release is enabled, the final binary file will be generated in the folder same as Makefile.

                                    Option Description
                                    debug_and_release_target This option is set by default. If debug_and_release is also set, the debug and release builds end up in separate debug and release directories.

                                    from: https://doc.qt.io/qt-5/qmake-variable-reference.html


                                    Correct me if I'm wrong. Thanks for your reading.

                                    1 Reply Last reply
                                    0
                                    • M Mozi

                                      The new discovery record:
                                      If I add build_pass, Qt Creator will complain about the Makefile after qmake:

                                      Could not parse Makefile. The build in \path\to\the\build will be overwritten.
                                      

                                      Well, I don't know if it's harmful to manually add this argument by the developer.
                                      It's not well-documented...

                                      The only build_pass phrase in the page (https://doc.qt.io/qt-5/qmake-variable-reference.html):

                                      During the latter passes, **build_pass** and the respective debug or release option is appended to CONFIG. This makes it possible to perform build-specific tasks. For example:
                                      
                                      build_pass:CONFIG(debug, debug|release) {
                                          unix: TARGET = $$join(TARGET,,,_debug)
                                          else: TARGET = $$join(TARGET,,,d)
                                      }
                                      
                                      M Offline
                                      M Offline
                                      Mozi
                                      wrote on last edited by
                                      #24

                                      Ummm, I missed this UN-document.

                                      ...
                                      
                                      There are also several values that qmake will dynamically set in CONFIG when it is writing a makefile (not when XCode project files are being written) other than the primary Makefile - i.e. the additional subsidiary makefiles when debug_and_release and/or static_and_shared have been set:
                                      
                                      * build_pass — a subsidiary makefile is being written (build_pass is not set when the primary Makefile is being written).
                                      * Debug and DebugBuild — when debug_and_release has been set and the makefile filename extension contains "Debug".
                                      * Release and ReleaseBuild — when debug_and_release has been set and the makefile filename extension contains "Release".
                                      * Static and StaticBuild — when static_and_shared has been set and the makefile filename extension contains "Static".
                                      * Shared and SharedBuild — when static_and_shared has been set and the makefile filename extension contains "Shared".
                                      
                                      ...
                                      

                                      from: https://wiki.qt.io/Undocumented_QMake#Config_features

                                      1 Reply Last reply
                                      0

                                      • Login

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