TTF_Font has initializer but incomplete type

Hello there,

I am using Mac OS X with XCode to create an SDL Application. I have
also added the SDL_ttf framework, and have included the freetype2
library in the c++ compiler flags. I am coding in C++.

Here is a snippet:

#include <SDL_ttf/SDL_ttf.h>

TTF_Font fntArial12 = TTF_OpenFont( “arial.ttf”, 12 );

I get the following error:

/Users/matt/Programming/SDLTag/Tag.cpp: In member function ‘void
Tag::render(SDL_Surface*)’:
/Users/matt/Programming/SDLTag/Tag.cpp:147: error: variable ‘TTF_Font
fntArial12’ has initializer but incomplete type

Does anybody have any ideas as to how to solve this issue?

Many thanks,
Matt Morten

Matt Morten wrote:

TTF_Font fntArial12 = TTF_OpenFont( “arial.ttf”, 12 );

You probably mean

TTF_Font *fntArial12 = TTF_OpenFont( “arial.ttf”, 12 );

-Christian

1 Like