What can explain std::cout not to display anything?

On Windows, programs usually are built as either a SUBSYSTEM:WINDOWS application or as SUBSYSTEM:CONSOLE.

Programs built with SUBSYSTEM:CONSOLE are expected to be text-mode applications. For this type of application, stdout and stderr print to the console that you launched them from, creating a new console if necessary.

In contrast, SUBSYSTEM:WINDOWS applications do not bother with a console. You can still write to stdout and stderr, but they normally don't go anywhere. You could use AllocConsole to create a console to print to, but this will always print to a newly created console window, not to a console window you launched the program from.

One trick for SUBSYSTEM:WINDOWS applications is that even though there's no console, you can still pipe stdout and stderr. To pipe stdout, you can do:

YourApplication.exe > output.txt

or if you have cat (or an equivalent):

YourApplication.exe | cat

Also note that there's not really any difference between SUBSYSTEM:WINDOWS applications and SUBSYSTEM:CONSOLE applications other than how Windows treats them when creating the process. (You can create windows in SUBSYSTEM:CONSOLE applications.) You therefore can easily switch between SUBSYSTEM types (for example, to use SUBSYSTEM:CONSOLE for debug builds and SUBSYSTEM:WINDOWS for release ones).


Ok, answer found. Simple answer, of course, as always when encountering such problems. Michael Aaron was on the right tracks.

Simply changing SubSystem to Console in project configuration (/Configuration properties/Linker/System) makes the whole thing work. The GUI still works, but with a background console. I can deal with that.


Try

CONFIG += console

in your .pro file.