Advice on MinGW and SDL (stdout and stderr)

On the advice of others in this group, I’ve gone ahead and ported my SDL
application to Windows under MinGW. There are still some small things
to work out, but I’m surprised at how easy it actually went.

One problem that I don’t know how to fix though. The application sends
stdout and stderr (as printed by cout and cerr in C++) to the files
stdout.txt and stderr.txt. It happens in a DOS box as well as MinGW’s
rxvt terminal. This is quite annoying, since the application is
commandline based and I want to see the command line messages.

I’ve looked through Google, but it seems that most people have the
output going to the screen, and want to redirect it to a file. I
haven’t yet found anyone who has the same problem I have, which is the
opposite.

Anyone know of a way around this?

Steve

You have to modify and recompile SDL. The file you want to modify is
winmain.c, I think. There’s a code there to close stdin & stdout and
replace it with file i/o - you’ll have to remove that and recompile, and
reinstall.

-MarkOn Wed, 3 Dec 2003, Stephen Anthony wrote:

On the advice of others in this group, I’ve gone ahead and ported my SDL
application to Windows under MinGW. There are still some small things
to work out, but I’m surprised at how easy it actually went.

One problem that I don’t know how to fix though. The application sends
stdout and stderr (as printed by cout and cerr in C++) to the files
stdout.txt and stderr.txt. It happens in a DOS box as well as MinGW’s
rxvt terminal. This is quite annoying, since the application is
commandline based and I want to see the command line messages.

I’ve looked through Google, but it seems that most people have the
output going to the screen, and want to redirect it to a file. I
haven’t yet found anyone who has the same problem I have, which is the
opposite.

Anyone know of a way around this?

Steve


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


Mark K. Kim
AIM: markus kimius
Homepage: http://www.cbreak.org/
Xanga: http://www.xanga.com/vindaci
Friendster: http://www.friendster.com/user.jsp?id=13046
PGP key fingerprint: 7324 BACA 53AD E504 A76E 5167 6822 94F0 F298 5DCE
PGP key available on the homepage

Actually, all that needs to be done is to recompile with "NO_STDIO_REDIRECT"
defined in src/main/SDL_main.c (you can either modify the file or re-compile
SDL_main.lib by hand with -DNO_STDIO_REDIRECT, your mileage may varry)> ----- Original Message -----

From: sdl@cbreak.org (Mark K. Kim)
To:
Sent: Tuesday, December 02, 2003 8:55 PM
Subject: Re: [SDL] Advice on MinGW and SDL (stdout and stderr)

You have to modify and recompile SDL. The file you want to modify is
winmain.c, I think. There’s a code there to close stdin & stdout and
replace it with file i/o - you’ll have to remove that and recompile, and
reinstall.

-Mark

On Wed, 3 Dec 2003, Stephen Anthony wrote:

On the advice of others in this group, I’ve gone ahead and ported my SDL
application to Windows under MinGW. There are still some small things
to work out, but I’m surprised at how easy it actually went.

One problem that I don’t know how to fix though. The application sends
stdout and stderr (as printed by cout and cerr in C++) to the files
stdout.txt and stderr.txt. It happens in a DOS box as well as MinGW’s
rxvt terminal. This is quite annoying, since the application is
commandline based and I want to see the command line messages.

I’ve looked through Google, but it seems that most people have the
output going to the screen, and want to redirect it to a file. I
haven’t yet found anyone who has the same problem I have, which is the
opposite.

Anyone know of a way around this?

Steve


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


Mark K. Kim
AIM: markus kimius
Homepage: http://www.cbreak.org/
Xanga: http://www.xanga.com/vindaci
Friendster: http://www.friendster.com/user.jsp?id=13046
PGP key fingerprint: 7324 BACA 53AD E504 A76E 5167 6822 94F0 F298 5DCE
PGP key available on the homepage


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


Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.541 / Virus Database: 335 - Release Date: 11/14/2003

One problem that I don’t know how to fix though. The application sends
stdout and stderr (as printed by cout and cerr in C++) to the files
stdout.txt and stderr.txt. It happens in a DOS box as well as MinGW’s
rxvt terminal. This is quite annoying, since the application is
commandline based and I want to see the command line messages.

Take a look at src/main/win32/SDL_main.c, which is linked into libSDLmain.a
You’ll want to enable the #define which turns off stdio redirection.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

One other question. If I do this, will the application open a DOS window
when it hasn’t been launched from DOS? I’d like it to work exactly like
it does on Linux. Specifically, if one launches from the commandline,
the output is seen in that window. But if one launches it from a GUI
interface, the output should go to null (I don’t want to see a DOS box
pop up). Is it possible to have both??

Thanks,
SteveOn December 3, 2003 04:50 am, Sam Lantinga wrote:

One problem that I don’t know how to fix though. The application
sends stdout and stderr (as printed by cout and cerr in C++) to the
files stdout.txt and stderr.txt. It happens in a DOS box as well as
MinGW’s rxvt terminal. This is quite annoying, since the application
is commandline based and I want to see the command line messages.

Take a look at src/main/win32/SDL_main.c, which is linked into
libSDLmain.a You’ll want to enable the #define which turns off stdio
redirection.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

I seem to recall using this during configuration successfully as well

–enable-stdio-redirect Redirect STDIO to files on Win32 [default=yes]

set it to no when you configure SDL and it’ll open a dos box for the stdio.

brian> ----- Original Message -----

From: sdl-admin@libsdl.org [mailto:sdl-admin at libsdl.org] On Behalf Of Mark
K. Kim
Sent: Tuesday, December 02, 2003 10:55 PM
To: sdl at libsdl.org
Subject: Re: [SDL] Advice on MinGW and SDL (stdout and stderr)

You have to modify and recompile SDL. The file you want to modify is
winmain.c, I think. There’s a code there to close stdin & stdout and
replace it with file i/o - you’ll have to remove that and recompile, and
reinstall.

-Mark

On Wed, 3 Dec 2003, Stephen Anthony wrote:

On the advice of others in this group, I’ve gone ahead and ported my SDL
application to Windows under MinGW. There are still some small things
to work out, but I’m surprised at how easy it actually went.

One problem that I don’t know how to fix though. The application sends
stdout and stderr (as printed by cout and cerr in C++) to the files
stdout.txt and stderr.txt. It happens in a DOS box as well as MinGW’s
rxvt terminal. This is quite annoying, since the application is
commandline based and I want to see the command line messages.

I’ve looked through Google, but it seems that most people have the
output going to the screen, and want to redirect it to a file. I
haven’t yet found anyone who has the same problem I have, which is the
opposite.

Anyone know of a way around this?

Steve


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


Mark K. Kim
AIM: markus kimius
Homepage: http://www.cbreak.org/
Xanga: http://www.xanga.com/vindaci
Friendster: http://www.friendster.com/user.jsp?id=13046
PGP key fingerprint: 7324 BACA 53AD E504 A76E 5167 6822 94F0 F298 5DCE
PGP key available on the homepage


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