Results 1 to 4 of 4

Thread: qmake Project file has both "debug" and "release" conditions true

  1. #1
    Join Date
    Nov 2009
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default qmake Project file has both "debug" and "release" conditions true

    Here's my project file:

    Qt Code:
    1. TARGET = trialApp
    2. TEMPLATE = app
    3.  
    4. win32 {
    5. debug {
    6. LIBS += -L../trialLibA/debug
    7. PRE_TARGETDEPS += ../trialLibA/debug/libtrialLibA.a
    8. }
    9. release {
    10. LIBS += -L../trialLibA/release
    11. PRE_TARGETDEPS += ../trialLibA/release/libtrialLibA.a
    12. }
    13. }
    14.  
    15. INCLUDEPATH += ../trialLibA
    16. LIBS += -ltrialLibA
    17.  
    18. SOURCES += main.cpp\
    19. MainWindow.cpp
    20. HEADERS += MainWindow.h
    21. FORMS += MainWindow.ui
    To copy to clipboard, switch view to plain text mode 


    The problem is that both "debug" and "release" are defined when the makefile is generated. (I had started with debug {} else {} but debug was always defined).

    In both Makefile.Debug and Makefile.Release, LIBS is defined to have both "-L../trialLibA/debug" and "-L../trialLibA/release".

    So, of course, when I build the app, it takes the debug library (even when building release) because it's listed first in the LIBS path.

    How is my understanding of the qmake process flawed here?
    Last edited by barryhf; 13th February 2010 at 01:34.

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Angry Re: qmake Project file has both "debug" and "release" conditions true

    From the Qt docs
    Scopes are similar to if statements in procedural programming languages. If a certain condition is true, the declarations inside the scope are processed.
    So your scope says that if the OS is win32 compile with debug and release libraries.

    Try something like this:
    Qt Code:
    1. CONFIG += debug
    2.  
    3. win32 {
    4. CONFIG(debug) {
    5. LIBS += -L../trialLibA/debug
    6. PRE_TARGETDEPS += ../trialLibA/debug/libtrialLibA.a
    7. } else {
    8. LIBS += -L../trialLibA/release
    9. PRE_TARGETDEPS += ../trialLibA/release/libtrialLibA.a
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Nov 2009
    Posts
    129
    Thanks
    4
    Thanked 29 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qmake Project file has both "debug" and "release" conditions true

    Quote Originally Posted by barryhf View Post
    How is my understanding of the qmake process flawed here?
    Your confusion is that you expect it to make sense, whereas this particular “feature” is entirely counter-intuitive.

    This explanation of the CONFIG function should help.

    The problem is that the CONFIG variable can (and usually does) contain conflicting options, such as both “debug” and “release”; only the last of conflicting options is effective, but an ordinary scope test only discovers whether an option is present, not whether it is effective. Using CONFIG(debug, debug|release), for example, will test whether “debug” is the last (and hence, effective) among the “debug” and “release” options.

  4. The following user says thank you to Coises for this useful post:

    barryhf (15th February 2010)

  5. #4
    Join Date
    Nov 2009
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qmake Project file has both "debug" and "release" conditions true

    Thank you, Coises, the following code now works to set the dependencies correctly (I can change a code file in the library, hit F5 and the app builds and links correctly).

    Another question: How does this effect the notion of "scopes" in general? Is it still valid to use the "win32" scope, or is there a different Conditional, such as CONFIG, that I should be using?

    Qt Code:
    1. TARGET = trialApp
    2. TEMPLATE = app
    3.  
    4. win32 {
    5. CONFIG(debug, debug|release) {
    6. LIBS += -L../trialLibA/debug
    7. PRE_TARGETDEPS += ../trialLibA/debug/libtrialLibA.a
    8. } else {
    9. LIBS += -L../trialLibA/release
    10. PRE_TARGETDEPS += ../trialLibA/release/libtrialLibA.a
    11. }
    12. }
    13.  
    14. INCLUDEPATH += ../trialLibA
    15. LIBS += -ltrialLibA
    16.  
    17. SOURCES += main.cpp\
    18. MainWindow.cpp
    19. HEADERS += MainWindow.h
    20. FORMS += MainWindow.ui
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 0
    Last Post: 15th November 2009, 10:40
  2. Replies: 3
    Last Post: 29th August 2009, 23:24
  3. Replies: 3
    Last Post: 8th July 2008, 20:37
  4. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 20:05
  5. QFile Problem~ "Unknow error" in "open(QIODevice::ReadWrite)"
    By fengtian.we in forum Qt Programming
    Replies: 3
    Last Post: 23rd May 2007, 16:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.