Jump to content

  • Log In with Google      Sign In   
  • Create Account

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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
16 replies to this topic

#1 Cheezmeister   Members   -  Reputation: 139

Like
0Likes
Like

Posted 30 April 2006 - 09:53 AM

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-

Sponsor:

#2 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

0Likes

Posted 30 April 2006 - 10:05 AM

http://www.libsdl.org/faq.php?action=listentries&category=7#55


#3 kloffy   Members   -  Reputation: 932

Like
0Likes
Like

Posted 30 April 2006 - 10:10 AM

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]

#4 Cheezmeister   Members   -  Reputation: 139

Like
0Likes
Like

Posted 30 April 2006 - 10:27 AM

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

#5 Cheezmeister   Members   -  Reputation: 139

Like
0Likes
Like

Posted 30 April 2006 - 10:46 AM

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.

#6 flashingchicken   Members   -  Reputation: 133

Like
0Likes
Like

Posted 30 April 2006 - 07:15 PM

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

#7 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

0Likes

Posted 30 April 2006 - 08:26 PM

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.


#8 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

0Likes

Posted 02 May 2006 - 10:17 AM

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?

#9 Cheezmeister   Members   -  Reputation: 139

Like
0Likes
Like

Posted 02 May 2006 - 12:58 PM

^that was me there, by the way. >_>

#10 nullsquared   Members   -  Reputation: 122

Like
0Likes
Like

Posted 02 May 2006 - 01:59 PM

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")



#11 Cheezmeister   Members   -  Reputation: 139

Like
0Likes
Like

Posted 03 May 2006 - 08:54 AM

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;
}


#12 HopeDagger   GDNet+   -  Reputation: 970

Like
0Likes
Like

Posted 03 May 2006 - 03:32 PM

Don't forget (under Code Generation in project properties) to make it a Multithreaded [Debug] DLL. [smile]

#13 Cheezmeister   Members   -  Reputation: 139

Like
0Likes
Like

Posted 04 May 2006 - 09:48 AM

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...

#14 Cheezmeister   Members   -  Reputation: 139

Like
0Likes
Like

Posted 04 May 2006 - 09:53 AM

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.

#15 Cheezmeister   Members   -  Reputation: 139

Like
0Likes
Like

Posted 04 May 2006 - 11:41 AM

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.


#16 peterallenwebb   Members   -  Reputation: 122

Like
0Likes
Like

Posted 18 January 2009 - 10:25 AM

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.

#17 minb2   Members   -  Reputation: 100

Like
0Likes
Like

Posted 02 July 2009 - 05:31 PM

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?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS