[SOLVED]SDL Compiling Problems

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
JaxDragon
Chaos Rift Junior
Chaos Rift Junior
Posts: 395
Joined: Mon Aug 04, 2008 2:03 pm
Current Project: Kanoba Engine
Favorite Gaming Platforms: PS3, PC
Programming Language of Choice: C++
Location: Northeast NC

[SOLVED]SDL Compiling Problems

Post 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'
Last edited by JaxDragon on Sat Apr 04, 2009 2:28 pm, edited 1 time in total.
User avatar
Maevik
Chaos Rift Junior
Chaos Rift Junior
Posts: 230
Joined: Mon Mar 02, 2009 3:22 pm
Current Project: www.keedepictions.com/Pewpew/
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: Long Beach, CA

Re: SDL Compiling Problems

Post 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.
My love is like a Haddoken, it's downright fierce!
User avatar
JaxDragon
Chaos Rift Junior
Chaos Rift Junior
Posts: 395
Joined: Mon Aug 04, 2008 2:03 pm
Current Project: Kanoba Engine
Favorite Gaming Platforms: PS3, PC
Programming Language of Choice: C++
Location: Northeast NC

Re: SDL Compiling Problems

Post 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.
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: SDL Compiling Problems

Post 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. ;)
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
JaxDragon
Chaos Rift Junior
Chaos Rift Junior
Posts: 395
Joined: Mon Aug 04, 2008 2:03 pm
Current Project: Kanoba Engine
Favorite Gaming Platforms: PS3, PC
Programming Language of Choice: C++
Location: Northeast NC

Re: SDL Compiling Problems

Post 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.
Post Reply