Page 1 of 1

[SOLVED]SDL Compiling Problems

Posted: Sat Apr 04, 2009 12:08 pm
by JaxDragon
I know my source code is correct, because I copied it straight from the LazyFoo site. I followed all the instructions from the page to get both my IDE's(Dev-C++, Code::Blocks), and yet they both give me the same error. And yes, I put the DLL files in the project folder. Heres the error:

Code: Select all

undefined reference to `_SDL_main'
Thats the error in Code::Blocks. Heres the error in Dev-C++.

Code: Select all

In function `console_main':
[Linker error] Undefined reference to `SDL_main'

Re: SDL Compiling Problems

Posted: Sat Apr 04, 2009 12:39 pm
by Maevik
It looks like you dont have the libraries linked in your dependencies. I'm not sure how to do this for code::blocks or Dev C++, but if you follow every step of his first tutorial you should be golden.

Also, I wouldn't recomment just copying lazyfoo's code. Only in the first tutorial (maybe two) does he give you all the code for a program that is functional. Most of the time you just get snippets. It's also a great way to memorize the SDL library if you type everything in by hand each time you do a tutorial.

Re: SDL Compiling Problems

Posted: Sat Apr 04, 2009 1:06 pm
by JaxDragon
When I said copied code I meant copied what he had by typing. I agree just copying source doesn't get you memorizing code. I still don't know what I'm doing wrong. I've had this problem before, I just keep forgetting how to fix it.

Re: SDL Compiling Problems

Posted: Sat Apr 04, 2009 1:52 pm
by Ginto8
JaxDragon wrote:When I said copied code I meant copied what he had by typing. I agree just copying source doesn't get you memorizing code. I still don't know what I'm doing wrong. I've had this problem before, I just keep forgetting how to fix it.
If you're using Code::Blocks, go to project->build options->linker settings, then in "Other linker options", put this:

Code: Select all

-lmingw32 -lSDLmain -lSDL
If you're using SDL_image add -lSDL_imge, for SDL_ttf add -lSDL_ttf etc. etc. ;)

Re: SDL Compiling Problems

Posted: Sat Apr 04, 2009 2:28 pm
by JaxDragon
I fixed it, the problem was that I forgot to put SDL_Quit() at the bottom of the code ^^. SDL has to be referenced/dereferenced for it to link properly.