How can I get console output instead of stdout.txt and stderr.txt?

SDL_Init() routes stdout and stderr to the respective files. You can revert this by adding the following lines after the call to SDL_Init in your code:

freopen( "CON", "w", stdout );
freopen( "CON", "w", stderr );


* If that doesn't work try adding these 2 lines at the very beginning of your code (SDL_Init wrapper or in top of your main)



For those of you using Visual Studio .NET (probably works with VC6 too), in project properties be sure to set linker->subsystem to CONSOLE, or your project won't be allowed to trigger a console even if you've done everything correctly.


If that doesn't work, another option is to recompile libSDLmain.a. The easiest way to do so is by using MinGW and MSYS:

$ cd /c/SDL-1.2.9
$ ./configure --disable-stdio-redirect
$ cd src/main
$ make


Another option is to include SDL-1.2.9\src\main\win32\SDL_win32_main.c from the SDL source in your project and then not link with libSDLmain.a at all. When you compile your program, be sure to pass -DNO_STDIO_REDIRECT to the compiler. Once again, also be sure that you don't pass -mwindows to the compiler.

FAQ_Console (last edited 2008-04-17 08:18:56 by localhost)