PDA

View Full Version : qdebug



drkbkr
28th September 2006, 21:29
Hello,

Is there some way to turn off qDebug with a compile or run time flag? When I build for release, I don't necessarily want the full debug output I want when developing, but I don't want to take all the output out of the code, either.

Any help would be appreciated.

Thanks,
Derek

wysota
28th September 2006, 21:49
CONFIG-=debug could probably help.

drkbkr
28th September 2006, 21:58
I thought so too. Probably should have included this before, but my .pro file contains

CONFIG+=qt release incremental link_prl
CONFIG-=debug

Do I have syntax wrong or something?

Thanks.

jacek
28th September 2006, 23:00
How about "DEFINES += QT_NO_DEBUG_OUTPUT"?

wysota
28th September 2006, 23:02
No, my mistake. I had to check the docs :) Add something like this to your project file:
DEFINES += QT_NO_DEBUG_OUTPUT

And again... Jacek was faster :)

drkbkr
28th September 2006, 23:15
Thank you both. But I'm still missing something.

My project file now looks like this, and qDebug still produces output.



################################################## ####################
# Automatically generated by qmake (1.07a) Thu Sep 28 17:09:30 2006
################################################## ####################

OBJECTS_DIR=.obj/
MOC_DIR=.moc/
DEFINES += QT_NO_DEBUG_OUTPUT
CONFIG = qt release incremental link_prl
TEMPLATE = app
DEPENDPATH += include src
INCLUDEPATH += . include

# Input
HEADERS += include/Chooser.h \
include/Configurator.h \
include/Creator.h \
include/Exerciser.h \
include/ExerciserException.h \
include/FileChooser.h \
include/logo.h \
include/ResultsFile.h \
include/Sender.h \
include/SequenceArguments.h \
include/SequenceSpecifier.h \
include/versioninfo.h
SOURCES += src/Chooser.cpp \
src/Configurator.cpp \
src/Creator.cpp \
src/Exerciser.cpp \
src/ExerciserException.cpp \
src/FileChooser.cpp \
src/ResultsFile.cpp \
src/Sender.cpp \
src/SequenceArguments.cpp \
src/SequenceSpecifier.cpp

wysota
28th September 2006, 23:30
Did you remember to rerun qmake (and rebuild all files from the project) afterwards?

jacek
28th September 2006, 23:30
Maybe you have to define QT_NO_WARNING_OUTPUT too?

drkbkr
29th September 2006, 14:40
I did both of the above things (although I'd probably like to keep warnings on) and I still get it. The compile command being run is like this:


g++ -c -pipe -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fomit-frame-pointer -march=i586 -mtune=pentiumpro -DQT_NO_DEBUG_OUTPUT -DQT_NO_WARNING_OUTPUT -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/usr/lib/qt3/mkspecs/default -I. -I. -Iinclude -I/usr/lib/qt3//include -I.moc/ -o .obj/Exerciser.o src/Exerciser.cpp

Derek

jacek
29th September 2006, 15:00
Since you use Qt3, not Qt4, try "DEFINES += QT_NO_DEBUG".

drkbkr
29th September 2006, 15:13
Still no luck.

The result of that is that it adds another -DQT_NO_DEBUG to the compile command (there was one there already as well), but I'm still getting output.

Derek

wysota
29th September 2006, 15:24
qDebug seems to be a function in Qt3, so it might be impossible to do that through Qt directly. But you can provide your own macro, which would expand to nothing if a certain macro is defined or to qDebug() if it is not (or vice versa) and use that macro instead of qDebug().

drkbkr
29th September 2006, 16:26
I thought it was possible to turn on and off the debug output easily with a compile time flag but I guess not.

The QT 3 docs say that the QT_DEBUG flag "Enables debugging code" and that the QT_NO_DEBUG flag turns off the QT_DEBUG flag. So I guess I don't know what exactly that means.

Anyway, I've created a macro that expands to qDebug, and it works fine.

Thanks to you both,

Derek