I run this program, don't see any output in the console, and it terminates immediatly. What am I doing wrong?
The code:
#include <iostream>
#include <SDL/SDL.h>
using namespace std;
int main(int argc, char *argv[]) {
//The images
cout << "Hello World" << endl;
SDL_Surface* hello = NULL;
SDL_Surface* screen = NULL;
//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );
//Set up screen
screen = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );
//Load image
hello = SDL_LoadBMP( "heldlo.bmp" );
//Apply image to screen
SDL_BlitSurface( hello, NULL, screen, NULL );
//Update Screen
SDL_Flip( screen );
//Pause
SDL_Delay( 20000 );
//Free the loaded image
SDL_FreeSurface( hello );
//Quit SDL
SDL_Quit();
return 0;
}
Using minGW, passing libraries:
mingw32 SDLmain SDL
Signature of main method seems to be correct, it's like here: simple tcp echo program not working when SDL included?
Or here, it's stated that the linker subsystem has to be console: http://www.gamedev.net/topic/376205-defeating-sdl-linker-errors-in-visual-studio-net/
So I tried passing
-Wl,--subsystem,console -mconsole both to the compiler and the linker. This builds and starts and is the same as before, no output, no window.
For me it doesn't make sense to pass option console, since, I actually want to see a window, but I'm a complete noob in this, so I have no idea. Just read people saying that SDL requires either program run with console option, OR changing the main method to WinMain. But then they also say that this doesn't make sense and SDL is supposed to run with main.
I also did a test passing "windows" instead of "console" to the linker, and compiler, also no success (it behaves the same).
I also don't understand why I don't see the output in the console. If I remove all the SDL stuff (specially, the include), it will show the output. Since it also executed very fast, I the main method probably is not being executed at all.
Any help...?