Can std :: cout be redirected to the output view in Visual Studio 2010 C ++ out of the box?

I want to know if this can be done in the latest version of VS by simple configuration somewhere, which leads to the fact that VS will behave as shown in "ContextMenu"> run "a_Java_src_file_with_main" in the Eclipse IDE. I am using the trial version of VS 2010 Pro on the new W7 platform. Even the minimal cpp helloworld source file added to the project generated from the "empty" template is redirected to the command window.

The same question 3 years ago:
Capturing cout in Visual Studio 2005 output window?
And 9 months ago:
How to redirect stdout to output window from visual studio

I know using OutputDebugString (...) and redirecting the stream to a file as an alternative.
Capturing console output for debugging in VS?

+5
source share
1 answer

An easy way to do this is to " close the console window ", the WinMain executable with the WinMain entry WinMain on the windows instead of main .

This can usually be done by editing the project settings, but if you use cmake , like me, these settings are overwritten every time you invoke the cmake assembly. Thus, in this case, you need to add WIN32 to the executable target in CMakeList.txt or set CMAKE_WIN32_EXECUTABLE to true for the cmake configure command .

0
source

Source: https://habr.com/ru/post/1386018/


All Articles