Author Topic: How to see output in a wxWidgets project?  (Read 11984 times)

Offline Otto

  • Multiple posting newcomer
  • *
  • Posts: 21
How to see output in a wxWidgets project?
« on: September 23, 2010, 12:41:48 am »
Hi,

I would like to know how do I check what was printed with a std::cout in a GUI (wx) during development.
I can't find any output window/view.

I only see output if I run the app outside C::B via CLI.


Thanks.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to see output in a wxWidgets project?
« Reply #1 on: September 23, 2010, 09:44:45 am »
Set the type of your project to console and it will show you the output :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Otto

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: How to see output in a wxWidgets project?
« Reply #2 on: September 25, 2010, 02:31:46 am »
That didn't work. The output window appears, but nothing is printed.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to see output in a wxWidgets project?
« Reply #3 on: September 25, 2010, 09:43:45 am »
That didn't work. The output window appears, but nothing is printed.
I just tested it (on linux) and it works fine.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to see output in a wxWidgets project?
« Reply #4 on: September 25, 2010, 10:58:04 am »
Hm, if you're on windows you should read here: http://msdn.microsoft.com/en-us/library/ms682073%28VS.85%29.aspx

You need AttachConsole + a way to redirect stdout/stdin to the console... let google be your friend...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to see output in a wxWidgets project?
« Reply #5 on: September 25, 2010, 11:58:57 am »
Hm, if you're on windows you should read here: http://msdn.microsoft.com/en-us/library/ms682073%28VS.85%29.aspx

You need AttachConsole + a way to redirect stdout/stdin to the console... let google be your friend...
Tested on Vista and it works out of the box.

Offline Otto

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: How to see output in a wxWidgets project?
« Reply #6 on: September 25, 2010, 05:16:11 pm »
I'm using Linux (Debian) and C::B 10.05.

I tested again and noticed it is only printed after I quit the program. I wasn't seeing because the output window is closed at that moment too. Have to keep "Pause when execution ends" checked.

Can't it be printed as soon as std::cout is called?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to see output in a wxWidgets project?
« Reply #7 on: September 25, 2010, 05:39:53 pm »
Tested again on linux (stepped through the code with debugger) and the output appears immediately after stepping over cout.

Offline Otto

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: How to see output in a wxWidgets project?
« Reply #8 on: September 25, 2010, 06:02:10 pm »
That's nice, but it doesn't work for me. Is there anything I can do?

Ps: you're testing in a GUI (configured later to console) app, right? The cout is called when I do a GUI action (Menu help > about).

Online stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: How to see output in a wxWidgets project?
« Reply #9 on: September 25, 2010, 06:15:12 pm »
Tested it and it works on Windows 6.1 AKA 7

Note: Flush was necessary to see output

Code
std::cout << "Test Message" << std::flush;

Remember to change project properties for target to "Console Application" and checkmark "Pause when Execution Ends"

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Otto

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: How to see output in a wxWidgets project?
« Reply #10 on: September 25, 2010, 06:46:39 pm »
Note: Flush was necessary to see output

Code
std::cout << "Test Message" << std::flush;
That was it! Thanks.

Sorry everyone, I'm new to C++.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to see output in a wxWidgets project?
« Reply #11 on: September 27, 2010, 05:55:27 pm »
I used std::endl as last argument and that also seems to flush.

Offline Otto

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: How to see output in a wxWidgets project?
« Reply #12 on: September 27, 2010, 11:55:52 pm »
I confirm endl is enough.