Skip to main content
gamedev.net
🔒 Locked

Silli problem with SDL+Dev-cpp

Started by Glubo Jun 6, 2004 at 6:47 AM 6 replies 550+ views
Original Post
Glubo
Glubo
I have a silly problem when using devcpp(4.9.8.0) with libsdl (from SDL-devel-1.2.7-mingw32.tar.gz). Linker gives me an error message, that I have no WinMain although I'm compiling it as a console program. Does anyone know how to set the devcpp for compiling&linking a code like this:
#include <SDL.h>

int main(int argc, char **argv)
{
	SDL_Surface *screen;
	bool done=false;
	SDL_Event event;
	
	if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
	{
		fprintf( stderr, "Video initialization failed: %s\n",
			SDL_GetError( ) );
		SDL_Quit( );
	}

	
	screen = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);

	if ( screen == NULL )
	{
		printf("Unable to set 640x480 video: %s\n", SDL_GetError());
		SDL_Quit();
		return 1;
	}


	while(!done)
	{
		while(SDL_PollEvent(&event))
		{
			if(event.type==SDL_QUIT)done=true;
			if(event.type==SDL_KEYDOWN)
			{
				if ( event.key.keysym.sym == SDLK_ESCAPE ) { done = 1; }
			};

		};
	};

	SDL_Quit();
	return 0;
};
[edited by - Glubo on June 6, 2004 7:49:01 AM]
Glubo the MadI am a signature virus. Please add me to your signature so that I may multiply.
Red Drake
Red Drake
Try remakeing your project - Copy the code in a new project.
When you star the new project use empty project instead of console app.
This MIGHT help , becouse it helped me several times - buth then it coud be SDL inplementing WinMain - i dont know anyithing specific about SDL
Red Drake
Deranged
Deranged
how many times has this come up, ITS IN THE LIBSDL.ORG FAQ!
are you linking with -lmingw32 -lSDLmain -lSDL -mwindows?



Sharp Basic - Coming summer 2004!
Sign Up For Sharp Basic Beta Testing!!!

[edited by - deranged on June 6, 2004 8:07:11 PM]
Deranged
Deranged
quote:
Original post by Anonymous Poster
You need to add the the mingw32 and SDLmain libraries to your project, either add these to your linker options:

-lmingw32 -lSDLmain

or if you have the latest version of dev-cpp, you can add them using the 'add library or object' button in the parameters tab in project options. The files will be under the lib directory in your dev-cpp install directory. The file names are libmingw32.a and libsdlmain.a

If that still doesn't work, then try adding the compiler option

-Dmain=SDL_main

in addition to those libraries.




as i said right above you, with dev-cpp you need -mwindows

[edited by - deranged on June 6, 2004 8:07:18 PM]
Glubo
Glubo
thanks for help, I've tried to google it out but with no answer...
the -mwindows switch makes it compile... Thank You again...

[edited by - Glubo on June 7, 2004 3:06:19 PM]
Glubo the MadI am a signature virus. Please add me to your signature so that I may multiply.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.