Make debug/release



  • 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!



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



  • 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.



  • 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?



  • 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?



  • 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.



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.