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