   help learning SDL
  I'm currently reading Focus on SDL, I'm in the first chapter were it teaches you to set up your IDE to develop with SDL. I entered the second piece of code in that chapter and i keep getting a build error. Here's the code:#include "sdl.h"#include <stdio.h>#include <stdlib.h>SDL_Surface* g_pMainSurface = NULL;SDL_Event g_Event;int main(int argc, char* argv[]){    if (SDL_Init(SDL_INIT_VIDEO)==-1)    {  fprintf(stderr,"Could not initialize SDL!\n");  exit(1);  }    else    {   fprintf(stdout,"SDL initialized properly!\n");   atexit(SDL_Quit);   }    g_pMainSurface = SDL_SetVideoMode(640,480,0,SDL_ANYFORMAT);    if(!g_pMainSurface)    {   fprintf(stderr,"Could not create main surface!\n");   exit(1);   }    for(;;)    { if(SDL_WaitEvent(&g_Event)==0) { fprintf(stderr,"Error while waiting for an event!\n"); exit(1); }  //check the type of event if(g_Event.type==SDL_QUIT) {  fprintf(stdout,"Quit event has occurred.\n");  break;  } } fprintf(stdout,"Terminating program normally.\n");    return 0;}Here's the error message:   multiple definition of 'SDL_main'   first defined hereId returned 1 exit statusC:\Dev-Cpp\FOSDL\Makefile   [Build Error] [FOSDL1_1.exe] Error 1I can't figure out what I've done wrong.[Edited by - rezz106 on June 28, 2009 6:09:21 PM]
 Does DevCPP finish compiling, and have the error while linking ? Or while compiling ? It looks like a header/include problem..   ;  I've used the headers #include <iostream>, #include <stream> and #include "sdl.h" when i compiled the first code in the book, to test whether or not i set every thing up right. I worked then, and originally with this code I used those headers and get the same error.   ;  It appears that your linker believes you have two SDL_main functions. Just so you are clear, when you write main() on windows using SDL, you are actually writing a function called SDL_main(). Given this clue, I can guess what might be the issue - I think you have created a single Dev-C++ project, and wrote the first piece of code, and it worked. When you entered the second piece of code, you did so inside the same project. So you have two versions of SDL_main (or main) and your compiler wants you to specify only one.If this is the problem, the solution is either to remove any code from the first example, or create a new project for each program you are entering.   ;  It could be that your project is somehow linking a mix of release and debug libraries. Or that you are linking something that has already linked SDL statically.I'm not used to DevCPP myself so I can't tell you exactly how to do this but the first thing I would try is to switch the project settings between debug and release mode to see if that changes anything.The last time I saw this issue, or a very similar one, was when I linked some debug libraries into a project that was set to release mode. What happened was that both the debug and the release versions of the library was linked, and hence the entry point was defined twice. I think the problem could be somewhere down this road but I'm not sure.A couple of questions that could help:- Are you linking any libraries other than SDL into your target?- Is your project settings set to release mode? (If there is such a thing in DevCPP)   ;Quote:Original post by rip-offIt appears that your linker believes you have two SDL_main functions. Just so you are clear, when you write main() on windows using SDL, you are actually writing a function called SDL_main(). Given this clue, I can guess what might be the issue - I think you have created a single Dev-C++ project, and wrote the first piece of code, and it worked. When you entered the second piece of code, you did so inside the same project. So you have two versions of SDL_main (or main) and your compiler wants you to specify only one.If this is the problem, the solution is either to remove any code from the first example, or create a new project for each program you are entering.thanks you were right to think that i put them in the same project. I did what you said and everything worked out, thanks   