PDA

View Full Version : qDebug() under Windows



jlbrd
19th October 2006, 14:20
Hello,

When a program is built in debug mode, qDebug() writes to stderr under Linux and Windows. In Release mode, under Linux qDebug() writes to stderr but under Windows the messages seems lost.
My question is how to write to stderr under Windows in release mode and with MinGW compiler. The goal is to read the messages when the program is launched in a QProcess.

e8johan
19th October 2006, 14:26
In windows you need to add the line "CONFIG += console" to you pro-file to get qDebug to work. This is because windows applications do not have stdin/out/err setup by default.

Antrax
19th October 2006, 14:28
why not use fprintf(stderr, "...")?

wysota
19th October 2006, 14:30
why not use fprintf(stderr, "...")?
It won't help without supporting the console. Using qDebug() for transfering actual data is a strange thing anyway. I'd suggest using cout or cerr instead and leave qDebug for debugging.

jlbrd
19th October 2006, 19:11
Thank you,

Indeed with console added to CONFIG variable, qQebug() wrote to output debug in QDevelop under Windows on Release mode. Only small default: If the application is on Debug mode and have console added, when the application is launched, a terminal is opened and the messages are written in it. But the goal is reached, thank you.

igor_x
26th October 2006, 11:19
and what to do, when i got error in
"MAKE -f makefile.debug" (CONFIG += console in pro file)

--
debug\mainwindow.o debug\moc_detailsdialog.o debug\moc_mainwindow.o -L"c:\Qt\4.2.0\lib" -
lQtGuid4 -lQtCored4
/mingw/lib/libmingw32.a(main.o)(.text+0x106):main.c: undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\printform.exe] Error 1
mingw32-make[1]: Leaving directory `C:/Qt/progi/printform'
mingw32-make: *** [debug] Error 2
--
thanks!
Igor

wysota
26th October 2006, 12:58
"make clean" your project. And be sure to run qmake after modifying the project file.

Bob Wilson
10th March 2007, 01:32
You may view the qDebug messages using Debug View:

http://www.microsoft.com/technet/sysinternals/utilities/debugview.mspx

You start it up in a separate window... can use when executing within QDevelop
or outside...

You can view the qDebug(...) messages without having to change your config...
DebugView was avail from sysinternal.com but Microsoft bought them...

When MS sees QDevelop... they will probably try to buy it!!!:)

I am not a Microsoft fan, but since someone else wrote it......

Arigreen
20th March 2007, 07:43
I'm having trouble getting qDebug to output anything when using MacOs. I added CONFIG += console to my .pro file but am still unable to read any debug output. Any ideas?

Thanks,
Ari

sunil.thaha
20th March 2007, 07:48
Try


config -= app_bundle # enable the qDebug() in mac

Arigreen
20th March 2007, 08:10
Yep, that worked! Thanks a lot!

Ari