Results 1 to 8 of 8

Thread: qmake debug/release scope and disabling debugging output

  1. #1
    Join Date
    Nov 2006
    Posts
    35
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default qmake debug/release scope and disabling debugging output

    I tried to configure the build process using the release/debug scopes in the qmake project file. For example I wanted to include some files and add a define in debug mode:
    Qt Code:
    1. debug {
    2. DEFINES += MODELTEST_RULETABLEMODEL
    3. INCLUDEPATH += 3rdparty/modeltest
    4. }
    To copy to clipboard, switch view to plain text mode 
    But even with "CONFIG += qt release uitools warn_on" the define and include from the debug scope are added to the Makefile.xxx.release. I had to add a "CONFIG -= debug" to the release project file as a workaround.

    Am I misunderstanding/-using the release/debug scope??

    Another problem: I wanted to disable debuging output by adding the define QT_NO_DEBUG_OUTPUT to the release scope. But then my app won't compile anymore as I used qDebug() << ...; often instead of qDebug("...", ...);. If I had known this in advance... I had thought that all qDebug("...", ...) and qDebug << ... calls would not be compiled in when not compiling the project in debug mode... and disabling does not work as expected...

    Any workaround for this issue?

    Thanks in advance,
    -Jens

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qmake debug/release scope and disabling debugging output

    Quote Originally Posted by No-Nonsense View Post
    But even with "CONFIG += qt release uitools warn_on" the define and include from the debug scope are added to the Makefile.xxx.release. I had to add a "CONFIG -= debug" to the release project file as a workaround.
    Try "!release" insted of "debug".

    Another problem: I wanted to disable debuging output by adding the define QT_NO_DEBUG_OUTPUT to the release scope. But then my app won't compile anymore as I used qDebug() << ...; often instead of qDebug("...", ...);. If I had known this in advance... I had thought that all qDebug("...", ...) and qDebug << ... calls would not be compiled in when not compiling the project in debug mode... and disabling does not work as expected...[/quote]
    Does the following application compile and work with the define set?
    Qt Code:
    1. #include <QtDebug>
    2.  
    3. int main(){
    4. qDebug() << "xyz";
    5. return 0;
    6. }
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to wysota for this useful post:

    No-Nonsense (12th March 2007)

  4. #3
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qmake debug/release scope and disabling debugging output

    Quote Originally Posted by No-Nonsense View Post
    I tried to configure the build process using the release/debug scopes in the qmake project file. For example I wanted to include some files and add a define in debug mode:
    Qt Code:
    1. debug {
    2. DEFINES += MODELTEST_RULETABLEMODEL
    3. INCLUDEPATH += 3rdparty/modeltest
    4. }
    To copy to clipboard, switch view to plain text mode 
    But even with "CONFIG += qt release uitools warn_on" the define and include from the debug scope are added to the Makefile.xxx.release. I had to add a "CONFIG -= debug" to the release project file as a workaround.

    Am I misunderstanding/-using the release/debug scope??
    when playing with debug/release builds it is recommended to use the CONFIG() test function instead of scopes :
    Qt Code:
    1. CONFIG(debug, debug|release) {
    2. # here comes debug specific statements
    3. } else {
    4. # here comes release specific statements
    5. }
    To copy to clipboard, switch view to plain text mode 
    Not only should it solve your problem but it also allows building your app in both modes (provided you specify a different target for each of them...)

    Quote Originally Posted by No-Nonsense View Post
    Another problem: I wanted to disable debuging output by adding the define QT_NO_DEBUG_OUTPUT to the release scope. But then my app won't compile anymore as I used qDebug() << ...; often instead of qDebug("...", ...);. If I had known this in advance... I had thought that all qDebug("...", ...) and qDebug << ... calls would not be compiled in when not compiling the project in debug mode... and disabling does not work as expected...

    Any workaround for this issue?
    I don't think you'll find any workaround for this...
    Current Qt projects : QCodeEdit, RotiDeCode

  5. The following user says thank you to fullmetalcoder for this useful post:

    No-Nonsense (12th March 2007)

  6. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qmake debug/release scope and disabling debugging output

    Quote Originally Posted by fullmetalcoder View Post
    I don't think you'll find any workaround for this...
    Is there a workaround needed? It seems to work fine for me...

  7. #5
    Join Date
    Nov 2006
    Posts
    35
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qmake debug/release scope and disabling debugging output

    Quote Originally Posted by wysota View Post
    Try "!release" insted of "debug".
    Great! Thanks! Works and doesn't mess qith QDevelop (that could not handle CONFIG -= debug or fullmetalcoders hints on how to do it the right way.

    Quote Originally Posted by wysota View Post
    [... QT_NO_DEBUG_OUTPUT ...]
    Does the following application compile and work with the define set?
    Qt Code:
    1. #include <QtDebug>
    2.  
    3. int main(){
    4. qDebug() << "xyz";
    5. return 0;
    6. }
    To copy to clipboard, switch view to plain text mode 
    It works, but it was my fault: I meant qWarning() << ...; instead of qDebug() << ...; I thought they would behave the same as qDebug() and qWarning() are mentioned in the Qt docs a debugging output functions that can be disabled each with its own define.

    Any idea how to solve the issue with qWarning() << ...; not compiling when defining QT_NO_DEBUG_OUTPUT?

    Thanks in advance,
    -Jens

  8. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qmake debug/release scope and disabling debugging output

    Sure. Use qDebug instead

    And seriously - you can't disable warning messages, these are not meant for debugging.

  9. #7
    Join Date
    Nov 2006
    Posts
    35
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: qmake debug/release scope and disabling debugging output

    Quote Originally Posted by wysota View Post
    Sure. Use qDebug instead
    Ok, maybe we do not talk about the same problem: defining QT_NO_DEBUG_OUTPUT should IMHO only disable qDebug(...); and qDebug() << ...; as the Qt docs say. But it will also disallow the use of qWarning() << ...; as this will lead to compilation errors (tested under Windows and Linux).

    Quote Originally Posted by wysota View Post
    And seriously - you can't disable warning messages, these are not meant for debugging.
    The Qt documentation states:

    Quote Originally Posted by Trolltech-Qt-Documentation
    Both qDebug() and qWarning() are debugging tools. They can be compiled away by defining QT_NO_DEBUG_OUTPUT and QT_NO_WARNING_OUTPUT during compilation.
    I do not want to compile away qWarning, only qDebug and leave the qWarning() << ...; calls compilable and functional.

    -Jens

  10. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qmake debug/release scope and disabling debugging output

    Yes, you are right. I'm currently trying to find a way to override it, but as for now in vain.

    The problem is this line in qglobal.h:
    Qt Code:
    1. #if (defined(QT_NO_DEBUG_OUTPUT) || defined(QT_NO_TEXTSTREAM)) && !defined(QT_NO_DEBUG_STREAM)
    2. #define QT_NO_DEBUG_STREAM
    3. #endif
    To copy to clipboard, switch view to plain text mode 

    And then comes:
    Qt Code:
    1. #ifndef QT_NO_DEBUG_STREAM
    2. Q_CORE_EXPORT_INLINE QDebug qDebug();
    3. Q_CORE_EXPORT_INLINE QDebug qWarning();
    4. Q_CORE_EXPORT_INLINE QDebug qCritical();
    5. #else
    6. inline QNoDebug qDebug();
    7. #endif
    To copy to clipboard, switch view to plain text mode 

    The problem is in lack of the "QDebug qWarning();" declaration.

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.