   SDL  Trouble? Look Here.
  Having trouble with SDL? I know I sure did when first learning it! Not that I still don't, but I realized that most of my problems were very similar. I've also noticed that the majority of problems posted here are very similar.Below are the most common mistakes I see on posts made here and in my own experience. If you're having trouble getting your game up and running in SDL, go through these few things first.warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:libraryThis happens when you forget to set your linker to use a multi-threaded DLL. This is a requirement for linking SDL unless you build SDL yourself.Visual Studio.NETMake sure you have at least one .cpp file in your project. It can be blank.Right-Click on your project name in the Solution Explorer and select "Properties".Select "C/C++" and then "Code Generation".Change "Runtime Library" to "Multi-threaded DLL" or "Multi-threaded Debug DLL".Dev-C++Get the DevPakerror LNK2001: unresolved external symbol _SDL_mainThis could happen for a couple of reasons. Most of the time it's because of the way the libraries need to be linked in the code. To resolve this, add these lines to your main source file, or to a header file linked into your main source file:#pragma comment(lib, "SDL.lib")#pragma comment(lib, "SDLmain.lib")If this doesn't work, then you might have a very subtle and sneaky problem. This one hasn't bitten me, but I've seen it get others. When using SDL, you cannot have a void parameter list for your main function. You must use the command line variables.int main(void) // Badint main()// Badint main(int argc char **argv) // GoodEverything compiles but the screen and/or a surface is blankThis one can be tricky once your program starts gaining size and you Separate your code. Make sure you initialize SDL's video system and set the video mode BEFORE attempting to render anything. The code to do this is:SDL_Init(SDL_INIT_VIDEO);/*YOUR_SCREEN_SURFACE*/ = SDL_SetVideoMode(WIDTH, HEIGHT, BPP, FLAGS);It is imperative that you declare your screen surface before you do this.Founts of SDL KnowledgeThere are plenty of people using SDL. This means that there is plenty of information about it on the internet. Below are some resources I find handy.SDLSDL Documentation WikiSDL API ReferenceSDL Tutorials @ Game Programming WikiCone 3D TutorialsUsing SDL(zip file)SDL with OpenGLOGL/SDL Framework(zip file)SDL/OGL Text Input(zip file)[Edited by - Rhaal on April 12, 2005 12:58:51 PM]
Quote:This happens when you forget to set your linker to use a multi-threaded DLL. This is a requirement for linking SDL.Actually; this is because sdl.lib includes other libraries that it shouldn't. Setting your own project to multi-threaded dll only works because then it doesn't also include those libraries. This is bad, as you end up using whatever library happened to be present when sdl.lib was compiled and not the possibly updated one available right now. The proper solution is to compile SDL yourself.   ;  Yes, but it works. I have a feeling people would rather do that than build their own. We are talking about SDL noobies, one of which I still am.Edit: I adjusted the post, however, to be more accurate. (And now I'm going to build my own SDL. Thanks for the tip [smile])   ;  Over at the game programming wiki, we're attempting to be a "fount of SDL knowledge" too :)Our SDL Tutorial page has a number of unique articles, and an extensive list of other helpful SDL sites!   ;  I say we all band together to promote and contribute to that Wiki [smile] I haven't been to that page in a looong time, niec to see the updates! I think I'll add some stuff as well   ;  I'm on board!   ;  Vote for:(x) Make it sticky!Lots of newbies have those problems (even me had problems with those error messages). Perhaps we all could create a site with all those common openal/sdl questions (nothing oversized, just common problems)I had no problem to help.   ;Quote:Original post by Ludi83Perhaps we all could create a site with all those common openal/sdl questions (nothing oversized, just common problems)That's what this site can be used for buddy [smile] Just a seperate section that has a list of all the bugs and stuff, then link to that specific page.   ;Quote:Original post by Drew_BentonbuddyYeah, you called me buddy ;)Okay, but then make that post with the link to that wiki sticky (yeah, nice, how do you call that that in english (wiki sticky), we call it a Reim :D)   ;  [edit] I see what you're asking now! We call it a "Rhyme". They are probably pronounced the same.Yes, Drew has many buddies [smile]As far as "wiki", it's not an English word. Well, it's in our dictionary now as the weblog thing, but it's actually Hawaiian, meaning "Quick".   