Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qmake with debug_and_release
Forum Updated to NodeBB v4.3 + New Features

Qmake with debug_and_release

Scheduled Pinned Locked Moved Qt Creator and other tools
8 Posts 4 Posters 13.4k 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.
  • E Offline
    E Offline
    eraserix
    wrote on last edited by
    #1

    Hello

    In our project, we build some of the code in debug and release mode, so we use CONFIG += debug_and_release. This works except for one thing: The so/binaries have the same name and are linked at the same location for debug and release builds. Because we usually do make -j3, debug and release builds link into the same file, screwing it up from time to time.

    We have set DESTDIR and OBJECTS_DIR depending on debug or release build. Why does qmake choose to link the so in neither of the two locations? It compiles .o-files into OBJECTS_DIR, then links the so in the directory where .pro file is residing, and only then copies the linked result into destdir.

    Different names would complicate the dependencies inside the project, because I'd need to change the names of our libraries in LIBS depending on debug/release build. Now I just have to change the path.

    I keep hearing about shadow builds, would they be of service in my case? Or can I have qmake rename the target when it is copied to DESTDIR?

    Thanks!
    Christoph

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      Have a look at "this wiki page":http://developer.qt.nokia.com/wiki/How_to_build_a_static_Qt_version_for_Windows_with_gcc, there is a description on how to do that:

      @
      CONFIG(debug, debug|release) {
      mac: TARGET = $$join(TARGET,,,_debug)
      win32: TARGET = $$join(TARGET,,,d)
      }
      @
      You can do the same with the TARGETDIR, but I have no QtCreator here to test the code. Should be something like:

      @
      CONFIG(debug, debug|release) {
      TARGETDIR = ..\debug
      }
      CONFIG(release, debug|release) {
      TARGETDIR = ..\release}
      @

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • E Offline
        E Offline
        eraserix
        wrote on last edited by
        #3

        What is TARGETDIR? Do you mean DESTDIR?

        When I rename the target, is there some simple way to handle dependencies inside the project? My project creates a bunch of shared objects and uses them for executables. If I start renaming TARGET, wouldn't I have to create something like that for every created shared obj:
        @CONFIG(debug, debug|release) {
        LIBS += myLib1_Debug myLib2_Debug
        }
        CONFIG(release, debug|release) {
        LIBS += myLib1_Release myLib2_Release
        }@

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          DESTDIR sounds reasonable :-)
          Yes, you have to do that renaming io9n you projects.

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • E Offline
            E Offline
            eraserix
            wrote on last edited by
            #5

            I thought about introducing a special variable for project internal libs. I can then just loop over this variable and "fix" the libraries name. I'm also tending to just give the debug compilation a special name and leave release as is.

            Thanks for the pointers! :)

            1 Reply Last reply
            0
            • G Offline
              G Offline
              GordonSchumacher
              wrote on last edited by
              #6

              Honestly, you really don't want OBJECTS_DIR to be the same between the builds either! (What happens if you inadvertently get a mixture of debug and release object files...?)

              What I've done in the past is something like:
              @debug_and_release:build_pass {
              CONFIG(debug, debug|release) {
              CURBUILD = debug
              } else {
              CURBUILD = release
              }

              DESTDIR      = $${OUT_PWD}/$${CURBUILD}
              OBJECTS_DIR  = $${OUT_PWD}/$${CURBUILD}/$$dirname($${_PRO_FILE_PWD_})
              MOC_DIR      = $${OBJECTS_DIR}
              UI_DIR       = $${OBJECTS_DIR}
              RCC_DIR      = $${OBJECTS_DIR}
              INCLUDEPATH += $${OBJECTS_DIR}
              LIBS        += -L$${DESTDIR}
              
              unset(CURBUILD)
              

              }@

              I'm not positive those are all actually necessary, but you get the idea anyway.

              1 Reply Last reply
              0
              • E Offline
                E Offline
                eraserix
                wrote on last edited by
                #7

                We have different directories for OBJECTS_DIR between debug/release builds, but adding MOC/UI_DIR seems like a good idea.

                And I think it finally "clicked" on shadow building with qmake and that it won't help with my original problem :(. debug_and_release will just drop the two makefile somewhere else than the .pro file, but still link stuff in the PWD of the Makefiles, "overlinking" each other...

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  racanu
                  wrote on last edited by
                  #8

                  I'm getting crazy trying to make it work the way I think it should. I must be misunderstanding something.

                  I would like to have qmake generate makefiles that produce the output (TARGET) in specific directories for debug and release. I've tried something on the lines of what you (and many others) suggest, but it simply doesn't work for me.

                  I have:

                  @TEMPLATE = lib
                  CONFIG = qt shared debug_and_release build_all

                  debug_and_release:build_pass {
                  CONFIG(debug, debug|release) {
                  TARGET = ColorAnalyzerSimulator_debug
                  DESTDIR = debug
                  } else {
                  TARGET = ColorAnalyzerSimulator_release
                  DESTDIR = release
                  }
                  }
                  DEPENDPATH += .
                  INCLUDEPATH += .

                  Input

                  HEADERS += ColorAnalyzerSimulator.h
                  SOURCES += ColorAnalyzerSimulator.cpp@

                  And I issue the command

                  @qmake -spec macx-g++ -o Makefile.mac Simulator.pro@

                  and when I look into the Makefile.mac.Debug, TARGET has the default name (Simulator) and DESTDIR is empty!!

                  I have tried many variations of these settings but no result. I've also tried a similar thing on Linux and still no result.

                  I really hope someone can help.

                  [quote author="GordonSchumacher" date="1292262276"]Honestly, you really don't want OBJECTS_DIR to be the same between the builds either! (What happens if you inadvertently get a mixture of debug and release object files...?)

                  What I've done in the past is something like:
                  @debug_and_release:build_pass {
                  CONFIG(debug, debug|release) {
                  CURBUILD = debug
                  } else {
                  CURBUILD = release
                  }

                  DESTDIR      = $${OUT_PWD}/$${CURBUILD}
                  OBJECTS_DIR  = $${OUT_PWD}/$${CURBUILD}/$$dirname($${_PRO_FILE_PWD_})
                  MOC_DIR      = $${OBJECTS_DIR}
                  UI_DIR       = $${OBJECTS_DIR}
                  RCC_DIR      = $${OBJECTS_DIR}
                  INCLUDEPATH += $${OBJECTS_DIR}
                  LIBS        += -L$${DESTDIR}
                  
                  unset(CURBUILD)
                  

                  }@

                  I'm not positive those are all actually necessary, but you get the idea anyway.[/quote]

                  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