Sign in to follow this  
Cheezmeister

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

Recommended Posts

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-

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
http://www.libsdl.org/faq.php?action=listentries&category=7#55

Share this post


Link to post
Share on other sites
What IDE are you using?
In Visual C++ Express this is the way to go:
File -> New -> Project...
Win32 -> Win32 Console Application -> Ok
Application 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]

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
Thanks, but it still won't work. Waaah! I must be overlooking something exceedingly stupid...code's thus:

#pragma comment(lib, "SDLmain.lib")
#pragma comment(lib, "SDL.lib")
#include "SDL/SDL.h"

int main(int argc, char* argv[] )
{
//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );

//Quit SDL
SDL_Quit();
return 0;
}

Share this post


Link to post
Share on other sites
I have multithreaded DLL set, but I did notice this:

1>LINK : warning LNK4044: unrecognized option '/lSDL'; ignored

the output window shaved it off; I'll see if I can figure out what I did wrong with that...

Share this post


Link to post
Share on other sites
Alright, found out what was causing that error: I didn't get rid of the -lSDL flag before I added the #pragma comments. Which still brings me back to where I started ;_; *sigh...* thanks again for bearing with me.

Share this post


Link to post
Share on other sites
Quote:
Original post by kloffy
What IDE are you using?
In Visual C++ Express this is the way to go:
File -> New -> Project...
Win32 -> Win32 Console Application -> Ok
Application 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!



Well I was right: I was doing something stupid--I didn't read your post closely enough! I skimmed "empty project" and said to myself "I did choose an empty project" and left it at that. Moral of the story? No skimming :D

I am curious though--what difference did making the project that way make? there were still no files in the project, and the linker settings etc. appeared to be the same...But it works. Thank you thank you thank you so much.

Share this post


Link to post
Share on other sites
For anyone else that might stumble across this thread. The answer is that in the project properties panel Linker -> System -> SubSystem must be set to "Windows (/SUBSYSTEM:WINDOWS). I can't remember exactly why it's necessary, but it probably has something to do with the linker treating WinMain() as the entry point instead of main().

Good luck.

Share this post


Link to post
Share on other sites
Hi!

I've read the whole thread because I had the same error message. I applied all recommendations given and it still doesn't work (even with Windows as a subsystem). Does anyone know?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this