Allowing stdin, stdout on Windows

Hello folks. I’m using SDL for an assignment in my computer graphics course.
I prefer to use (and develop) on Linux, and thanks to SDL being
cross-platform I’ve not had too much trouble booting into Windows to compile
the program for Windows (I have to hand it in that way). But with my current
program, I have a bit of a problem. SDL is catching my stdout and stdin,
which I need to have sent and taken from the console. The program asks the
user for some parameters (not as command-line arguments) before it gets down
to business. Now, from looking around at the FAQS and docs on
libsdl.orghttp://libsdl.org,
I found SDL_win32_main.c to be of interest. I found

#ifndef NO_STDIO_REDIRECT

in several parts of the file, and it seemed like the obvious solution. So I
compiled with -DNO_STDIO_REDIRECT (Dev-C++). It didn’t fix the problem. So
now I’m wondering, must I write my own WinMain? Or is there an easier way to
get the behavior I’m looking for? I could just change the program to take
the input from the command line parameters, but it makes using the program a
lot more ambiguous. Any help will, as always, be greatly appreciated!

Matthew R. Hurne

Hi i had the same problem.

The solution is you have to compile the SDL_win32_main.c with
-DNO_STDIO_REDIRECT as an lib in dev-c++.
And then you should have rename your compiled lib file to libSDLmain.a
Now you have your own compiled SDL_Main.
Now you can replace the orginal libSDLmain.a with yours.
So you have to recompile your project with the new libSDLmain.a.

I have an allready compiled libSDLmain.a and it works.All stdin, stdout goes
to the console.
If you want i can send your the file.

2005/10/9, Matthew Hurne <matthew.hurne at gmail.com>:

Hello folks. I’m using SDL for an assignment in my computer graphics
course. I prefer to use (and develop) on Linux, and thanks to SDL being
cross-platform I’ve not had too much trouble booting into Windows to
compile
the program for Windows (I have to hand it in that way). But with my
current program, I have a bit of a problem. SDL is catching my stdout and
stdin, which I need to have sent and taken from the console. The program
asks the user for some parameters (not as command-line arguments) before
it
gets down to business. Now, from looking around at the FAQS and docs on
libsdl.org http://libsdl.org, I found SDL_win32_main.c to be of
interest. I found

#ifndef NO_STDIO_REDIRECT

in several parts of the file, and it seemed like the obvious solution. So
I compiled with -DNO_STDIO_REDIRECT (Dev-C++). It didn’t fix the problem.
So now I’m wondering, must I write my own WinMain? Or is there an easier
way to get the behavior I’m looking for? I could just change the program
to> take the input from the command line parameters, but it makes using the
program a lot more ambiguous. Any help will, as always, be greatly
appreciated!

Matthew R. Hurne


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Thanks Vardar. I ended up recompiling SDL with mingw and msys. I
used --disable-stdio-redirect with the configure script and then used
the new libSDLmain.a and it works. I also tried just using the file
itself in my project and not linking with libSDLmain.a, which also
worked. So no doubt I could’ve just compiled SDL_win32_main.c into
libSDLmain.a like you said and that probably would have worked as
well. At any rate, I’m grateful! I’m going to add this to the SDL
wiki because the method that’s currently on there didn’t even work for
me!On 10/9/05, Vardar Sahin wrote:

Hi i had the same problem.

The solution is you have to compile the SDL_win32_main.c with
-DNO_STDIO_REDIRECT as an lib in dev-c++.
And then you should have rename your compiled lib file to libSDLmain.a
Now you have your own compiled SDL_Main.
Now you can replace the orginal libSDLmain.a with yours.
So you have to recompile your project with the new libSDLmain.a.

I have an allready compiled libSDLmain.a and it works.All stdin, stdout
goes to the console.
If you want i can send your the file.

2005/10/9, Matthew Hurne <@Matthew_Hurne>:

Hello folks. I’m using SDL for an assignment in my computer graphics
course. I prefer to use (and develop) on Linux, and thanks to SDL being
cross-platform I’ve not had too much trouble booting into Windows to
compile
the program for Windows (I have to hand it in that way). But with my
current program, I have a bit of a problem. SDL is catching my stdout and
stdin, which I need to have sent and taken from the console. The program
asks the user for some parameters (not as command-line arguments) before
it
gets down to business. Now, from looking around at the FAQS and docs on
libsdl.org, I found SDL_win32_main.c to be of interest. I found

#ifndef NO_STDIO_REDIRECT

in several parts of the file, and it seemed like the obvious solution.
So
I compiled with -DNO_STDIO_REDIRECT (Dev-C++). It didn’t fix the problem.
So now I’m wondering, must I write my own WinMain? Or is there an easier
way to get the behavior I’m looking for? I could just change the program
to
take the input from the command line parameters, but it makes using the
program a lot more ambiguous. Any help will, as always, be greatly
appreciated!

Matthew R. Hurne


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl