Entry point must be defined.

Pages: 12
#include "SDL/SDL.h"
#include <iostream>


int main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Surface* screen; //back thing for the screen
screen=SDL_SetVideoMode(640,480,32,SDL_SWSURFACE); //
bool running=true; //boolean variable for program running
while(running) //while program is running
{
SDL_Event event;
while(SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_QUIT:
running=false;
break;
}
}
//logic & render
SDL_Flip(screen); //
}
SDL_Quit();
return 0;
}

fatal error LNK1561: Entry point must be defined.
closed account (N36fSL3A)
What compiler are you using?
"LNK1561" says Visual C++ to me...

But what entrypoint is the linker complaining about?

Andy
Don't forget to link with SDL_main or whatever the lib is called.
Seems it's SDLmain.lib

This thread is about the same linker error; even though it's for Visual C++ 2008, I think it should apply to your case.

How do you get a minimal SDL program to compile and link in visual studio 2008 express?
http://stackoverflow.com/questions/396183/how-do-you-get-a-minimal-sdl-program-to-compile-and-link-in-visual-studio-2008-e

Andy
I'm using Microsoft Visual 2010.
closed account (N36fSL3A)
Are you linking SDLmain.lib like asked above?
Yes, I did that. I'm still getting the same error.
If that is your exact, complete program, and you have told it to link with SDLmain.lib, then there is something wrong with your setup or your project options.

Alas, I don't know what exactly it is. The error message means that the compiler is not linking with SDLmain.lib, which is where main() is actually defined in an SDL app. (SDL #defines main as something else, so your main is that something else, which SDL's main calls.)
closed account (S6k9GNh0)
In Windows while using C++, you need to define main with extern "C" because of how it defines it in SDL_main.h.

http://hg.libsdl.org/SDL/file/6a145dedc972/include/SDL_main.h

EDIT: Stop using SDL 1.2 damnit.
Last edited on
Holy crap! Duh! I totally missed that!





/me sits in corner with dunce cap
closed account (N36fSL3A)
In Windows while using C++, you need to define main with extern "C" because of how it defines it in SDL_main.h.
No you don't. I never do and it works. Just include "SDL.h"

EDIT: Stop using SDL 1.2 damnit.
Well, there aren't any decent 2.0 tutorials. You have to learn 1.2 then migrate.
closed account (S6k9GNh0)
You don't need a tutorial for everything. Rather a lot of libraries around have terrible documentation and you have to use them anyways. SDL is one of the better ones.

EDIT: I'm not implying that you have to dive into SDL with nothing. The wiki provides extensive information on everything and each header has doxygen notes. It's pretty self explanatory.
Last edited on
Should I try using a different compiler other than Visual or does it not matter? What compilers do you prefer?
closed account (N36fSL3A)
I tried diving into SDL headfirst with no tutorials and failed miserably. I recommend 1.2 first then 2.0 still.

Josh, it really doesn't matter.
closed account (S6k9GNh0)
I don't understand how you would fail miserably.

Do NOT use 1.2 then 2.0. That's like learning OpenGL 1.2 then jumping up to OpenGL 3.3. It makes absolutely no sense to learn techniques that are now beyond deprecated and labeled as wrong.

Lumpkin wrote:
No you don't. I never do and it works. Just include "SDL.h"


Yes, you do. The library changes the definition of "main(int argc, char *argv[])" to "SDL_main(int argc, char *argv[])" then calls that with C linkage from an internal entry point. It's done this way to help define a more uniform entry point.
Last edited on
@Lumpkin
Why are you so adamantly pressing bad advice on the OP?

computerquip has not only posted correct information, he has had to refute your incorrect information a couple of times. But you seem undeterred. Perhaps you should consider this before posting a topic in the Lounge wondering why you are being reported?
You should be able to use VS to get this working. The problem is something with your project settings. You might want to create a new project from scratch. Ensure that you select a console application which outputs an executable, otherwise the entry point could get renamed to something like DLLmain() or WinMain().

Also, are you dynamically or statically linking SDL? Do you have the source of SDL or are you linking to the binary directly?
OK, this is what I have done. I tried to link the .lib files through the project settings looking at numerous videos seeing if I did it right, in which I did. I tried using a different compiler to see if it would work doing everything that you all told me and it still could not compile. I may be completely missing something. Does anyone have a Skype in which they can guide me through this, if you have the spare time, because i'm determined to figure this out and get past this block that I haven't got past for these two weeks. Thanks in advance.
In MSVS, you can also link inline.
#pragma comment(lib, "path/to/my/lib.lib")

Try that and remove the project linker.
Pages: 12