   Quick question in SDL
  Ok, so I'm just now starting to learn SDL...and I think I over prepared for it dramatically.Now considering this is the first API that I've tried to use with C++, I'm having some obvious issues.  I'm pretty sure that I have my project set up correctly.  I've been trying to learn through the LazyFoo tutorials, and the first one pretty much showed me that I've set it up correctly.  I've double checked and the linking settings are set up right, everything.  I have the updated version of SDL.dll in my system32 folder (which tested out right in the first tutorial) and after this doing the second one and failing, I even put another copy in the project folder.Sorry, I'm babbling.  Let my make this a little more simple.  I have a 2 linker errors in my project (tutorial #2 from Lazy Foo's SDL tutorials) and I would like to know what I'm doing wrong.  I'm not going to bother posting the source code, as you can see it from the website if you wish, not to mention this isn't a syntax error it is a linker error, but I will post the build output.1>------ Build started: Project: SDL Tut 2, Configuration: Debug Win32 ------1>Linking...1>SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol _SDL_main referenced in function _main1>C:\Documents and Settings\jd-inflames\My Documents\Visual Studio 2008\Projects\SDL Tuts\SDL Tut 2\Debug\SDL Tut 2.exe : fatal error LNK1120: 1 unresolved externals1>Build log was saved at "file://c:\Documents and Settings\jd-inflames\My Documents\Visual Studio 2008\Projects\SDL Tuts\SDL Tut 2\SDL Tut 2\Debug\BuildLog.htm"1>SDL Tut 2 - 2 error(s), 0 warning(s)========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========   
  The SDL_main.lib provides a main for you, that calls SDL_main, you have to provide it a SDL_main function.  Either change your main to SDL_main, or don't link to SDL_main.lib.   ;  Make sure your main function is defined as:int main( int argc, char* argv[] )Make sure you are linking against SDL.lib and SDLmain.libEdit: Fixed the wrong version of "your" above ;)   ;  Another note -- take SDL.dll out of your System32 directory -- you don't want it to be globally accessible to windows. Should you run any other program that requires SDL and it uses a different version than what you put in system32 it won't work right. Windows checks system32 first, then the program directory.Move it instead to your program directory (if you're running out of your debug/release directories also put a copy in there).   ;  Ok, I've tried both renaming main() to SDLmain() and then trying removing SDLmain.lib.  Either method produces the same error.As for SDL.dll being in my system32 folder, this is on a development machine of mine.  The only programs it runs are programs that I write.  That being said, the event of using a different version of SDL is rather controlled.   ;  as ontheheap said:your main should be likeint main(int argc,char *args[])   ;  Ok, I realized issue one was that I was using args() instead of args[].  Kind of a silly mistake, but it was simple enough that it explains why I overlooked it.  It compiles now with no error, but now I'm getting run time errors.  I'll go ahead and post the source to make things easier to look at in case I made another stupid boo boo like the above.//The Headers#include "SDL.h"#include <string>//The attributes of the screenconst int SCREEN_WIDTH = 640;const int SCREEN_HEIGHT = 480;const int SCREEN_BPP = 32;//The surfaces that will be usedSDL_Surface *message = NULL;SDL_Surface *background = NULL;SDL_Surface *screen = NULL;SDL_Surface *load_image(std::string filename){//Temporary storage for the image that's loadedSDL_Surface* loadedImage = NULL;//The optimized image that will be usedSDL_Surface* optimizedImage = NULL;//Load the imageloadedImage = SDL_LoadBMP(filename.c_str());//If nothing went wrong in loading the imageif (loadedImage != NULL){//Create an optimized imageoptimizedImage = SDL_DisplayFormat(loadedImage);//Free the old imageSDL_FreeSurface(loadedImage);}//Return the optimized imagereturn optimizedImage;}void apply_surface(int x, int y, SDL_Surface* source, SDL_Surface* destination){//Make a temporary rectangle to hold the offsetsSDL_Rect offset;//Give the offsets to the rectangleoffset.x = x;offset.y = y;//Blit the surfaceSDL_BlitSurface(source, NULL, destination, &offset);}int main(int argc, char* args[]){//Initialize all SDL subsystemsif (SDL_Init(SDL_INIT_EVERYTHING) == -1){return 1;}//Set up the screenscreen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE);//If there was an error in setting up the screenif (screen = NULL){return 1;}//Set up the window captionSDL_WM_SetCaption("Hello World", NULL);//Load the imagesmessage = load_image("hello_world.bmp");background = load_image("background.bmp");//Apply the background to the screenapply_surface(0, 0, background, screen);//Apply the message to the screenapply_surface(180, 140, message, screen);//Update the screenif (SDL_Flip(screen) == -1){return 1;}//Wait 2 secondsSDL_Delay(2000);//Free the surfacesSDL_FreeSurface(message);SDL_FreeSurface(background);//Quit SDLSDL_Quit();//Returnreturn 0;};//Set up the screenscreen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE);// if (screen = NULL)   // <--- Whoops, this assigns NULL to screen, then evaluates the result (NULL is 0, which is always false)if (screen == NULL)    // <--- This checks if screen is NULL{return 1;}//Set up the window captionSDL_WM_SetCaption("Hello World", NULL);//Load the imagesmessage = load_image("hello_world.bmp");background = load_image("background.bmp");// Check to see if your images are loading correctly here; you don't want// to spend any time looking at your apply_surface function or the SDL_Flip// function wondering why your images aren't being displayed  :)if ( message == NULL || background == NULL )  {return 1;}/*...*///Free the surfacesSDL_FreeSurface(message);SDL_FreeSurface(background);SDL_FreeSurface(screen);  // <--- Don't forget this!;SDL_FreeSurface(screen);  // <--- Don't forget this!Actually, that has no effect. I really don't remember where I saw that in the first place, I had to lurk into SDL source to find out: (snippet of SDL_surface.c)/* * Free a surface created by the above function. */void SDL_FreeSurface (SDL_Surface *surface){/* Free anything that's not NULL, and not the screen surface */if ((surface == NULL) ||    (current_video &&    ((surface == SDL_ShadowSurface)||(surface == SDL_VideoSurface)))) {return;}...}To really free the screen surface, you have to call SDL_Quit(). That is really something not to forget about. This function will call SDL_VideoQuit(), which will actually free the screen surface.   