5

I want to know if this can be done in the latest version of VS by a simple setting somewhere that causes VS to behave in a way that is equivalent to "ContextMenu">run "a_Java_src_file_with_main" in the Eclipse IDE. I'm using the trial version of VS 2010 Pro on a new W7 platform. Even the minimal helloworld cpp source file added to a project generated from the "empty" template redirects into a command window.

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'm aware of using OutputDebugString(...) and of redirecting the stream to a file as alternatives.
Capture console output for debugging in VS?

Community
  • 1
  • 1
wjohnson
  • 711
  • 1
  • 8
  • 19
  • possible duplicate of [How to redirect stdout to output window from visual studio](http://stackoverflow.com/questions/5248704/how-to-redirect-stdout-to-output-window-from-visual-studio) – Mark Ingram Jan 14 '13 at 09:06
  • Possible duplicate of [Redirect Console.Write... Methods to Visual Studio's Output Window While Debugging](https://stackoverflow.com/questions/2518509/redirect-console-write-methods-to-visual-studios-output-window-while-debuggi) – mr NAE Dec 21 '18 at 14:46

1 Answers1

0

Simple way to do this is to "suppress the console window" by building an executable with a WinMain entry point on 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 call the cmake build. So, in this case you need to add WIN32 to executable target in CMakeList.txt or set CMAKE_WIN32_EXECUTABLE to true for cmake configure command.

mr NAE
  • 3,144
  • 1
  • 15
  • 35