View Full Version : qmake debug/release scope and disabling debugging output
No-Nonsense
10th March 2007, 10:38
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:
debug {
DEFINES += MODELTEST_RULETABLEMODEL
INCLUDEPATH += 3rdparty/modeltest
}
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
wysota
10th March 2007, 12:06
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?
#include <QtDebug>
int main(){
qDebug() << "xyz";
return 0;
}
fullmetalcoder
10th March 2007, 12:19
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:
debug {
DEFINES += MODELTEST_RULETABLEMODEL
INCLUDEPATH += 3rdparty/modeltest
}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 :
CONFIG(debug, debug|release) {
# here comes debug specific statements
} else {
# here comes release specific statements
}
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...:rolleyes:)
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...
wysota
10th March 2007, 13:04
I don't think you'll find any workaround for this...
Is there a workaround needed? It seems to work fine for me...
No-Nonsense
12th March 2007, 11:22
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.
[... QT_NO_DEBUG_OUTPUT ...]
Does the following application compile and work with the define set?
#include <QtDebug>
int main(){
qDebug() << "xyz";
return 0;
}
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
wysota
12th March 2007, 12:37
Sure. Use qDebug instead ;)
And seriously - you can't disable warning messages, these are not meant for debugging.
No-Nonsense
12th March 2007, 15:41
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).
And seriously - you can't disable warning messages, these are not meant for debugging.
The Qt documentation states:
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
wysota
12th March 2007, 15:48
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:
#if (defined(QT_NO_DEBUG_OUTPUT) || defined(QT_NO_TEXTSTREAM)) && !defined(QT_NO_DEBUG_STREAM)
#define QT_NO_DEBUG_STREAM
#endif
And then comes:
#ifndef QT_NO_DEBUG_STREAM
Q_CORE_EXPORT_INLINE QDebug qDebug();
Q_CORE_EXPORT_INLINE QDebug qWarning();
Q_CORE_EXPORT_INLINE QDebug qCritical();
#else
inline QNoDebug qDebug();
#endif
The problem is in lack of the "QDebug qWarning();" declaration.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.