Results 1 to 11 of 11

Thread: qDebug() under Windows

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    156
    Thanked 12 Times in 12 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default qDebug() under Windows

    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.
    QDevelop, an complete Integrated Development Environment for Qt 4: http://qdevelop.org

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qDebug() under Windows

    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.

  3. #3
    Join Date
    Oct 2006
    Posts
    18
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qDebug() under Windows

    why not use fprintf(stderr, "...")?

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

    Default Re: qDebug() under Windows

    Quote Originally Posted by Antrax View Post
    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.

  5. #5
    Join Date
    Jan 2006
    Posts
    156
    Thanked 12 Times in 12 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qDebug() under Windows

    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.
    QDevelop, an complete Integrated Development Environment for Qt 4: http://qdevelop.org

  6. #6
    Join Date
    Oct 2006
    Posts
    13
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qDebug() under Windows

    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

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

    Default Re: qDebug() under Windows

    "make clean" your project. And be sure to run qmake after modifying the project file.

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

    igor_x (27th October 2006)

  9. #8
    Join Date
    Mar 2007
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qDebug() under Windows

    You may view the qDebug messages using Debug View:

    http://www.microsoft.com/technet/sys...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......

  10. #9
    Join Date
    Mar 2007
    Posts
    2
    Platforms
    MacOS X

    Default Re: qDebug() under Windows

    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

  11. #10
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qDebug() under Windows

    Try
    Qt Code:
    1. config -= app_bundle # enable the qDebug() in mac
    To copy to clipboard, switch view to plain text mode 
    We can't solve problems by using the same kind of thinking we used when we created them

  12. #11
    Join Date
    Mar 2007
    Posts
    2
    Platforms
    MacOS X

    Default Re: qDebug() under Windows

    Yep, that worked! Thanks a lot!

    Ari

Similar Threads

  1. Deploying with MySQL support under Windows
    By KShots in forum Installation and Deployment
    Replies: 1
    Last Post: 12th October 2006, 09:19
  2. converting unix exe to windows binary
    By deekayt in forum General Programming
    Replies: 2
    Last Post: 17th September 2006, 01:00
  3. Experience using KDevelop with Cygwin under windows
    By high_flyer in forum General Discussion
    Replies: 4
    Last Post: 11th September 2006, 16:50
  4. qt and mingw can not run on windows 98?
    By evewei in forum Installation and Deployment
    Replies: 4
    Last Post: 26th June 2006, 09:22
  5. MDI windows without QWorkspace
    By Big Duck in forum Newbie
    Replies: 2
    Last Post: 16th June 2006, 17:15

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
  •  
Qt is a trademark of The Qt Company.