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. Make debug/release
Forum Updated to NodeBB v4.3 + New Features

Make debug/release

Scheduled Pinned Locked Moved Qt Creator and other tools
7 Posts 3 Posters 11.1k 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.
  • N Offline
    N Offline
    nakagawa
    wrote on last edited by
    #1

    Hello

    In our project, we build the codes in debug and release mode(i.e. $ make debug, or $ make release).
    And my Project structure looks like this:

    @myproject
    |-main.cpp
    |-qmake.pro
    |-compile
    |-makefile
    |-Makefile
    |-Makefile.Debug
    |-Makefile.Release
    |-debug
    |-bin
    |-object
    |-release
    |-bin
    |-object
    @

    My qmake.pro looks like this:

    @TEMPLATE = app
    CONFIG = debug_and_release debug_and_release_target
    CONFIG(debug, debug|release) {
    DESTDIR = $$PWD/compile/debug/bin
    OBJECTS_DIR = $$PWD/compile/debug/object
    LIBS = some library for debug build(e.g. mylib_d.so)
    } else {
    DESTDIR = $$PWD/compile/release/bin
    OBJECTS_DIR = $$PWD/compile/release/object
    LIBS = some library for release build(e.g. mylib.so)
    }
    SOURCES = $$PWD/main.cpp
    @

    qmake generates Makefile.Debug and Makefile.Release, then we can build in both mode.
    However the problem is that the same library links in debug and release mode.

    Is there any solution for this?

    Thanks!

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      I'm not quite sure about your question. So ... doesn't work?
      @
      CONFIG(debug, debug|release) {
      LIBS += -lmylib_d
      } else {
      LIBS += -lmylib
      }
      @

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nakagawa
        wrote on last edited by
        #3

        Yes ... it works in the case i add the one line to the qmake.pro:

        @CONFIG += debug/release@

        but what i want to do is something like that:
        @myproject/compile/makefile$ qmake ../../qmake.pro
        myproject/compile/makefile$ make debug@

        for debug build.

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

          What platform is this on? Pretty much all projects I worked in that used mixed debug and release builds benefitted from introducing out of source builds, and having separate build directories for debug and release. Is this an option for you?

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

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nakagawa
            wrote on last edited by
            #5

            What platform is this on?

            ubuntu 11.10

            Pretty much all projects I worked in that used mixed debug and release builds benefitted from introducing out of source builds, and having separate build directories for debug and release. Is this an option for you?

            Yes that is what i want to do!
            How should i write in qmake.pro?

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

              Actually, in this case it should be a lot simple - your .pro files should not contain anything like this:

              @
              CONFIG = debug_and_release debug_and_release_target
              @

              because that overrides the build type. Make a build directory, and run qmake there like this:

              @

              for a debug build

              qmake CONFIG+=debug

              for a release build

              qmake CONFIG+=release
              @

              If you need to link different libs, Lukas' solution should work:

              @
              CONFIG(debug, debug|release) {
              LIBS += -lmylib_d
              } else {
              LIBS += -lmylib
              }
              @

              I think your problem is mostly that you override the build type in the .pro file, instead of passing it in.

              To get rid of debug_and_release, you may need to add CONFIG-=debug_and_release to the QMake call. Make sure to check which of debug, release and debug_and_release are set when QMake is executed, for example by printing messages.

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

              1 Reply Last reply
              0
              • N Offline
                N Offline
                nakagawa
                wrote on last edited by
                #7

                i got it!
                it works quite well.
                Thanks for your advice.

                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