News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

How to see output in a wxWidgets project?

Started by Otto, September 23, 2010, 12:41:48 AM

Previous topic - Next topic

Otto

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.

oBFusCATed

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!]

Otto

That didn't work. The output window appears, but nothing is printed.

Jenna

Quote from: Otto on September 25, 2010, 02:31:46 AM
That didn't work. The output window appears, but nothing is printed.
I just tested it (on linux) and it works fine.

oBFusCATed

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!]

Jenna

Quote from: oBFusCATed 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...
Tested on Vista and it works out of the box.

Otto

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?

Jenna

Tested again on linux (stepped through the code with debugger) and the output appears immediately after stepping over cout.

Otto

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).

stahta01

Tested it and it works on Windows 6.1 AKA 7

Note: Flush was necessary to see output


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++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

Otto

Quote from: stahta01 on September 25, 2010, 06:15:12 PM
Note: Flush was necessary to see output


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

That was it! Thanks.

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

Jenna

I used std::endl as last argument and that also seems to flush.

Otto