Jump to content
  • Advertisement

Archived

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

Tszafran

Newbie SDL Question

This topic is 6090 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

Hello, I have the SDL installed correctly and can compile Cone3D tutorials, but when I tried my own creation I get errors and have no clue why. Source Code below... #include #include #include SDL_Surface *Screen; SDL_Surface *Grass; int XPos=0,YPos=0; //------------------------------------------------- void InitImages(void) { Grass=SDL_LoadBMP("grass.bmp"); } //------------------------------------------------- void DrawImage(SDL_Surface *Image, int X, int Y) { SDL_Rect Dest; Dest.x=X; Dest.y=Y; SDL_BlitSurface(Image, NULL, Screen, &Dest); } //------------------------------------------------- void main(void) { if (SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO)<0) { printf("Unable to initialize SDL: %s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit); Screen=SDL_SetVideoMode(800,600,32,SDL_HWSURFACE|SDL_DOUBLEBUF); if(Screen==NULL) { printf("Unable to set to 800x600 video: %s\n", SDL_GetError()); exit(1); } InitImages(); int Done=0; while(Done==0) { SDL_Event Event; while(SDL_PollEvent(&Event)) { if(Event.type==SDL_QUIT) {Done=1;} } DrawImage(Grass,5,5); SDL_Flip(Screen); } } MSVC++ --------------------Configuration: lesson2 - Win32 Debug-------------------- Compiling... lesson2.cpp Linking... SDLmain.lib(SDL_main.obj) : error LNK2001: unresolved external symbol _SDL_main Debug/lesson2.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. lesson2.exe - 2 error(s), 0 warning(s) Im 100% precent sure I am linking the libraries, etc.. Can anyone give me some helpful ideas?

Share this post


Link to post
Share on other sites
Advertisement
Now I''m no SDL expert, but it seems like SDL is looking for an entry point called SDL_main(), while you are only using main().

Share this post


Link to post
Share on other sites
Your an expert in my books, it seems i cannot have my main as

void main();

but rather

int main(int argc, char *argv[])

Thanks alot.

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!