Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2010 C++ not displaying console output, despite console subsystem setting

I've got a project that creates a console application, as part of a larger solution, however it won't display anything on the console. I've checked that /SUBSYSTEM:CONSOLE is set for both debug and release, and tried both std::cout and printf, neither cause any output to be displayed.

The whole VS solution consists of a couple of static libraries containing the underlying business code, and three executable - the main GUI (QT/OpenGL), the unit tests (boost), and this console app. Some of the library classes use Qt (mainly for signals/slots). Both the GUI and the Unit tests behave as expected (which, in the case of the tests, includes writing to console output ).

I've also tried adding a call to AllocConsole at the start of the main function - this causes a console window to appear, but there is still nothing being written - and yes, I have checked that the code is calling cout!

What else could be wrong? Is there another setting somewhere? or is Qt redirecting stdout without telling me?

like image 809
Nick C Avatar asked Dec 11 '14 16:12

Nick C


1 Answers

It turned out that Visual Studio was over-riding the /SUBSYSTEM:CONSOLE setting with a /SUBSYSTEM:WINDOWS one in the Linker->Command Line->Additional Options page - deleting this made it work correctly...

like image 187
Nick C Avatar answered Oct 19 '22 09:10

Nick C