Under Windows textoutput to stdout.txt instead of commandline :-(

Hi,

My game asks before it initializes the SDL graphics mode, some
informationen from the user with cin and cout in textmode.
The problem is, that the textoutput of the game is written to a file
called stdout.txt in windows instead of displaying it to the monitor
since I compile my game with MinGW. In Linux it works great!

Is there any possibility to change that?

thanks,–
Ioan-Tudor Parvulescu <@Ioan-Tudor_Parvulesc>
www.itpsoft.de

Hi,

In ./configure --help it says:

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

so try --disable-stdio-redirect :slight_smile:

Cheers

JG

Ioan-Tudor Parvulescu wrote:> Hi,

My game asks before it initializes the SDL graphics mode, some
informationen from the user with cin and cout in textmode.
The problem is, that the textoutput of the game is written to a file
called stdout.txt in windows instead of displaying it to the monitor
since I compile my game with MinGW. In Linux it works great!

Is there any possibility to change that?

Hi,
But what can one do if he uses already compiled version of the library (dll)?

I have other kind but a bit similar problem:

program.exe argument

doesn’t work at all - program.exe doesn’t take any arguments…

Greetings

nellOn Thu, Feb 20, 2003 at 11:22:16PM +0000, J. Grant wrote:

Hi,

In ./configure --help it says:

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

so try --disable-stdio-redirect :slight_smile:


Escape of the Unicorn
[free, 2D, flying shooter game]
http://eounicorn.sourceforge.net

Hi,
But what can one do if he uses already compiled version of the library (dll)?

You can’t do anything about that, AFAIK. Not under Win32 anyway.

I have other kind but a bit similar problem:

program.exe argument

doesn’t work at all - program.exe doesn’t take any arguments…

Your main is declared as:

int main(int argc, char *argv[])

Right?On Fri, 2003-02-21 at 12:35, Justyna Bia?a wrote:

On Fri 21 Feb 03 19:17, Shawn wobbled:> On Fri, 2003-02-21 at 12:35, Justyna Bia?a wrote:

Hi,
But what can one do if he uses already compiled version of the library
(dll)?

You can’t do anything about that, AFAIK. Not under Win32 anyway.

How about something like:

FILE *outStream;
outStream = freopen( “stdout.txt”, “w”, stdout );


be seeing you

dazza at home

mail: @dazza

Support Electronic Freedom: http://www.eff.org
Annoyed? http://www.faxyourmp.com

I have other kind but a bit similar problem:

program.exe argument

doesn’t work at all - program.exe doesn’t take any arguments…

Change your shell. check your code. put in debug printf for argv and argc.

JG

It’d be better for SDL to not mess up stdout at all by default, especially
under MingW/Cygwin. (A cross-platform library that we have to add hacks
to remove annoying behavior under specific platforms? That’s backwards. :slight_smile:

(You might try reopening stdout to “con”.)On Fri, Feb 21, 2003 at 08:58:49PM +0000, dazza wrote:

FILE *outStream;
outStream = freopen( “stdout.txt”, “w”, stdout );


Glenn Maynard

Ioan-Tudor Parvulescu wrote:

My game asks before it initializes the SDL graphics mode, some
informationen from the user with cin and cout in textmode.
The problem is, that the textoutput of the game is written to a file
called stdout.txt in windows instead of displaying it to the monitor
since I compile my game with MinGW. In Linux it works great!

Is there any possibility to change that?

Yes. I’m compiling under MinGW and I found that I had to mess around
with a bunch of different main routines to get it to do output to the
command-line console as expected.

On MinGW, I build with -Dmain=SDL_main for the .c file containing my
’real’ main routine. Then I build a separate extra .c file just for
MinGW that I call main_redir.c:

//
// For Windows, redirect the main routine to run console_main()
// in SDL, so that we get console STDOUT and STDERR as expected.
//

extern int console_main(int, char **);

int
main(int ac, char **av) {
return console_main(ac, av);
}

// END //

Linking all this together with -lSDLmain and running it did the job
for me. So these ingredients seem to be necessary:

Use “-Dmain=SDL_main” when building the file with the real main()
routine

Build main_redir.c

Link with “-lmingw32 -lSDLmain -lSDL” etc

I can’t remember all the reasons for this now, but I guess if you
search through the SDL source for ‘main’ you will be able to figure it
out.

Jim

P.S. I’m cross-compiling windows .EXEs now from Linux using the
mingw32 cross-compiler that comes with Debian, which is great and
saves a great deal of time. See my site for more details of the
projects I’m working on.–
Jim Peters ()/=~/() @Jim_Peters
(
) /=\ ~/_ ()
Uaz? (
) /=\ ~/_ () http://
B’ham, UK (
) ____ /=\ ____ ~/_ ____ (_) uazu.net

SBaGen: binaural beats for brainwave entrainment: http://uazu.net/SB

Well, the original reason that code was there was to avoid requiring a debugger
for seeing output to stdout under MacOS and Windows - this predates the MinGW
environment.

Removing the behavior is very easy, just edit SDL_main.c and link with it
instead of SDLmain.lib (or -lSDLmain) … there’s a prominent comment at the
top.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment> On Fri, Feb 21, 2003 at 08:58:49PM +0000, dazza wrote:

FILE *outStream;
outStream = freopen( “stdout.txt”, “w”, stdout );

It’d be better for SDL to not mess up stdout at all by default, especially
under MingW/Cygwin. (A cross-platform library that we have to add hacks
to remove annoying behavior under specific platforms? That’s backwards. :slight_smile: