Combined GUI and Console APP?


I currently have a JUCE GUI application. But now I have to add a Console. I.e. I need to print text using printf. I cannot use DBG() (explanation see below).
Is there a way to do this in JUCE? The Introjucer only lets you choose between either GUI or Console application. But I need both.

If you wonder, why I need to use printf: I am writing an OpenCL application. And the only way to debug OpenCL, which I know of at the moment, is using “printf” in the OpenCL kernel. The printf output from the OpenCL is shown on the console.

I am on Juce 4.2.4, VS 2015 and Win 7.

Try this…

#include <stdio.h>
#include <Windows.h>

class PrintDebugConsole
		SetConsoleTitle (TEXT ("Juce Debug Window"));
		freopen("conin$", "r", stdin);
		freopen("conout$", "w", stdout);
		freopen("conout$", "w", stderr);

		std::cout << "Welcome..." << std::endl;


static const PrintDebugConsole staticPrintConsole = PrintDebugConsole();

My windows knowledge is not the best, but I think you can run your program from CMD.exe, so you will get the normal output from stdout.
And the second note instead of DBG: you can use the normal Logger class. If no Logger is set, it will print to stdout as well. The main benefit is, that you can see output from release builds as well.

Thanks for you help.
That worked, both of it.