Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Glubo

Silli problem with SDL+Dev-cpp

This topic is 5218 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
Guest 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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
It works fine without -mwindows, certainly on the latest few versions anyway.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!