Hey, I am starting to work with SDL and I had it all set up correctly etc. The thing that does not seem to be working correctly is the SDL_ttf. Now, As far as I am aware, linux builds don't use truetype, which is why I am at a loss of how to link this part of the code.

I am trying to compile and run a sample program given to me by my lecturer, I am using codeblocks IDE. It compiles fine, but I get a segmentation fault when I run it. When I ran the debugger, it showed the segmentation fault was happening directly after the TTF_Init(), when the font style was trying to be set.

TTF_SetFontStyle( g_font, TTF_STYLE_NORMAL );


I have linked SDL and SDL_ttf to my codeblocks project, using the -lSDL -lSDL_ttf commands respectively.

I am guessing there is something I need to do to tell it to use the FreeType font, but I have no idea how.

Any help is appreciated.

Ok this is getting ridiculous. I have just spent the last 3 hours on #SDL irc channel and I ended up where I started. I get a segmentation fault even if I compile and link from the terminal. The guys in IRC were talking about libSDL_ttf.a and libSDL_ttf.pc and stuff like that, which is all way over my head. I need some serious help or I think I may die of lack of sleep over the next few days.

Oh good god. The reason there was a seg fault was because g_font was null. This was because I set the font to be "arial.ttf" but the file was called "ARIAL.TTF". Please, if anybody finds this thread searching for a soln to a similar problem, check your damn spelling and capitals! Linux is case sensitive.