Can't Get SDL Started!

Started by
22 comments, last by ozzoright 18 years ago
Quote:Original post by twoaterisn
off course..

sorry about that, i thought i had the latest version.
everything is installed now, but i still can't make it work. when compiling some examples i get linker errors: undefined reference to 'SDL_RWfromfile' etc...

i added the devcpp\include\SDL directory to the C++ includes directories mentioned in the compiler options but that didn't help. do i need to do anything else or is reïnstalling the whole bunch the way to go?

greetings, T


That is good and all, but you need to do this:
1) Find the libSDLmain.a and libSDL.a files and put them in your devcpp/lib directory. Then in linker options (they are to the right of the compiler options, iirc), put:
-lmingw32-lSDLmain-lSDL

2) Find and put the SDL.dll file into your .exe directory or system32 directory.... Atleast for windows this is the way.

Linking errors occur when you haven't linked the libraries, as in step 1. Then if you link but can't run the exe itself and it tells you it's missing SDL.dll it's because you didn't do step 2.

I think you have the headers right... I mean, it found the function names.
EDIT: Note: The 'l's are lower-case 'L's, not upper-case 'i's.
Advertisement

I had allready done all that, but appearantly these settings (step 1) don't apply if you don't put your code in a project and just in a source file, like i did.
it's working now. not what i wanted it to do, but at least it's doing something :)

but thanx anyway!!

I did all of that too. My IDE says that the "SDL/SDL.h" directory doesn't exist, but I've done everything the tutorial told me to do.

[Edited by - ozzoright on April 18, 2006 12:52:16 PM]
maybe SDL\SDL.h
I have a problem using the TTF library. it gives me a runtime error on this line:

font = TTF_OpenFontIndex("arial.ttf", 16, 0);

or

font = TTF_OpenFont( "arial.ttf", 28 );

(i tried both)

this gives NULL for font, which i declared a global variable:

TTF_Font *font = NULL;

i put arial.ttf in the same directory as the .exe and using other fonts gives the same result. is there a specific folder i should put the .ttf files in?

Quote:Original post by twoaterisn
I have a problem using the TTF library. it gives me a runtime error on this line:

font = TTF_OpenFontIndex("arial.ttf", 16, 0);

or

font = TTF_OpenFont( "arial.ttf", 28 );

(i tried both)

this gives NULL for font, which i declared a global variable:

TTF_Font *font = NULL;

i put arial.ttf in the same directory as the .exe and using other fonts gives the same result. is there a specific folder i should put the .ttf files in?


Did you TTF_Init()?
yes, this in my "bool init()" function:

if( TTF_Init() == -1 )
{
return false;
}

but it doesn't complain about the commands i'm using, it just fails to open the font.
My error message changed after installing SDL via the Dev-C++ updater... now I have a build error.
To both people who have problems:

Post the line that has an error, and the error messages.

[edit:]Or, better yet, if your program is under a hundred lines of code, post the whole thing with <source> and </source> tags around it. (but switch '<' '>' with '[' ']' on the tags)
I'll gladly look it over.
i had the same problem, try deleting the first sdl from "sdl/sdl.h".

This topic is closed to new replies.

Advertisement