(SDL) "entry point must be defined" in init program

Started by
15 comments, last by minb2 14 years, 9 months ago
I'm new to this, so bear with me :) I'm trying to build the bare-bones SDL init program from Lazy Foo', and I get the following error: 1>LINK : fatal error LNK1561: entry point must be defined The code's: #include "SDL/SDL.h" int main(int argc, char* args[] ) { //Start SDL SDL_Init( SDL_INIT_EVERYTHING ); //Quit SDL SDL_Quit(); return 0; } I've followed the directions on where files belong, double and triple checked it, but I still get the error...what's an entry point and how do I define it? Thanks-
Advertisement
http://www.libsdl.org/faq.php?action=listentries&category=7#55
What IDE are you using?
In Visual C++ Express this is the way to go:
File -> New -> Project...Win32 -> Win32 Console Application -> OkApplication Settings -> Windows Application                        Empyt Project -> Ok

I hope this is understandable...

Edit:
Well, did you try creating a new project like I explained above? I just copied your code into my project and it worked. I'm sure it has something to do with the way you setup your project, because I had that error, too...
(You have to add SDL.lib and SDLmain.lib to your dependencies as well, but I think you did that already anyways...)

One more thing:
Perhabs you'll have to do this first, to be able to select "Windows Application". Good luck!

[Edited by - kloffy on April 30, 2006 5:10:23 PM]
Yeah, I'm using Express. Sorry 'bout that.
Thanks for the link, Anonymous. Got a solution and a half, as well as some good-to-know insight. Now, here's hoping it works :D
OK, the first instruction's the aggravation.

You must include either SDLMain.m/.h or libSDLmain in your application, because this is the code that defines SDL's entry point. If you fail to do this, it is likely that "_main undefined" will be thrown by the linker.

Of the three, SDLMain.m, as far as I know does not exist as a file on my computer, and I don't know how I would include that (as a dependency or as a header?);

SDLMain.h is included implicitly by #including SDL.h, and doesn't solve the problem;

libSDLmain doesn't have an extension specified there, and it doesn't appear to exist either. I DO have SDLmain.lib as a dependency, but that isn't the same, is it?

Thanks again for being patient.
are you sure that you are linking it in right, like with the -lSDL flag?
Quote:Original post by Cheezmeister
OK, the first instruction's the aggravation.

You must include either SDLMain.m/.h or libSDLmain in your application, because this is the code that defines SDL's entry point. If you fail to do this, it is likely that "_main undefined" will be thrown by the linker.

Of the three, SDLMain.m, as far as I know does not exist as a file on my computer, and I don't know how I would include that (as a dependency or as a header?);

SDLMain.h is included implicitly by #including SDL.h, and doesn't solve the problem;

libSDLmain doesn't have an extension specified there, and it doesn't appear to exist either. I DO have SDLmain.lib as a dependency, but that isn't the same, is it?

Thanks again for being patient.


You must link with libSDL and libSDLmain. There are probably files named SDL.lib and SDLmain.lib (or maybe libSDL.lib and libSDLmain.lib), somewhere in the -devel package of SDL.

SDLMain.m is only needed if you're programming in Objective C, and then likely only if you're targeting Mac OS (I believe it does some Carbon magic). You won't find it in the Windows package of SDL.

Sorry for not being more helpful, but I use GNU/Linux exclusively and don't know Windows all that much.


Hope this helps.
There are probably files named SDL.lib and SDLmain.lib (or maybe libSDL.lib and libSDLmain.lib), somewhere in the -devel package of SDL.

Yeah, I'm linked to both of those.

are you sure that you are linking it in right, like with the -lSDL flag?

No, I'm not sure. How would I do that?
^that was me there, by the way. >_>
Quote:Original post by Anonymous Poster
There are probably files named SDL.lib and SDLmain.lib (or maybe libSDL.lib and libSDLmain.lib), somewhere in the -devel package of SDL.

Yeah, I'm linked to both of those.

are you sure that you are linking it in right, like with the -lSDL flag?

No, I'm not sure. How would I do that?


Well... -lSDL is for GCC. You can use this for VC2k5EE:
#pragma comment(lib, "SDLmain.lib")#pragma comment(lib, "SDL.lbi")

This topic is closed to new replies.

Advertisement