SDL + MinGW + C++

Hi,

I have a problem with SDL when using C++ in MinGW. The problem is
basically the following;

I have a main-function declared correctly (int main(int argc, char*
argv[])) and include SDL.h in the same file. Everything compiles fine,
but my main-function is never called. I guess this has something to do
with the fact that the SDL_main is called first, but why doesn’t it
recognize my main-function?

My main-function look like this (cutted out some code due to the size).
I don’t get any output at all from the first line after compiling.

int main(int argc, char *argv[])
{
cout << “Game starting…” << endl;

MainGame* game = new MainGame();
game->Init(); // This is where SDL_Init is called

// Additional code here
}

regards,
Erik

Erik Hellman wrote:

Hi,

My main-function look like this (cutted out some code due to the size).
I don’t get any output at all from the first line after compiling.

SDL redirect stdout to stdout.txt by default.
look in this file, try to compile your application in console mode (no
-mwindows)

Gautier

i think you will also need to recompile sdlmain making sure to add:
#define NO_STDIO_REDIRECT 1

it’s very easy to do, it even has it’s own makefile. It’s in \src\main\ of
the sdl source package.> ----- Original Message -----

From: gautier@tlk.fr (Gautier Portet)
To:
Sent: Wednesday, March 24, 2004 9:53 AM
Subject: [SDL] Re: SDL + MinGW + C++

Erik Hellman wrote:

Hi,

My main-function look like this (cutted out some code due to the size).
I don’t get any output at all from the first line after compiling.

SDL redirect stdout to stdout.txt by default.
look in this file, try to compile your application in console mode (no
-mwindows)

Gautier


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

SDL redirect stdout to stdout.txt by default.

but why SDL redirect the stdout?!?!?!?!?!?!?

Muzero

Because on most platforms (including your average Un*x with graphical
desktop), the normal way to start an application does not involve a
console. Even in cases where the desktop environment pops up a
console if needed (Win32 console apps), the console tends to just
flash by so fast you’re lucky if you even see it…

So, stdout is effectively equivalent to /dev/nul for most "average"
users, regardless of OS.

It’s easier to tell users to look for two text files named stdout.txt
and stderr.txt, than to figure out and explain how to run an
application “from the console” on their particular OS. (Could you
explain how to do that on KDE, Gnome, CDE, Win95/98/ME, Win2k/XP, Mac
OS classic and Mac OS X, just for starters? :slight_smile:

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Monday 29 March 2004 19.43, Muzero wrote:

SDL redirect stdout to stdout.txt by default.

but why SDL redirect the stdout?!?!?!?!?!?!?

SDL redirect stdout to stdout.txt by default.

but why SDL redirect the stdout?!?!?!?!?!?!?

Because in Windows you don’t normally want games to create a console
window. By redirecting stdout it ensures any error message or such like
sent to stdout won’t be lost in the ether.

JamesOn Mon, 29 Mar 2004 19:43:58 +0200, Muzero wrote:

David Olofson wrote:

console. Even in cases where the desktop environment pops up a
console if needed (Win32 console apps), the console tends to just
flash by so fast you’re lucky if you even see it…

Or better say: unlucky, since it would mean that you computer is really
slow. :wink:

I would just add one more thing to these arguments:

having stdout and stderr as files is great for debugging. For example,
on Windows 98, all output in console that exists the screen is lost. The
only way to catch it is to redirect to some file. SDL does that for you.

And one more thing: On Linux, when is start game from console, I do get
output to stdout and I’m able to read it on screen.

I’d just like to say “thanx” to SDL developers for inventing such smart
way of handling this “stdout/stderr” issue.–
Milan Babuskov
http://njam.sourceforge.net