SDL_ttf compilation problem (and solution)

Hi all,

I tried compiling SDL_ttf (2.0.6) with FreeType (2.1.7) and get an error
while compiling SDL_ttf.lo.
It was not the problem of FT_OPEN_STREAM (the line “font->args.flags =
ft_open_stream;” worked “out of the box” for my platform [Linux 686
2.4.22-gentoo-r7 with gcc 3.3.2]) but of FreeTypes includes.

I got :

In file included from SDL_ttf.c:42:
/home/sye/Projects/OSDL/OSDL-0.3/src/conf/LOANI-installations/FreeType-2.1.7/include/freetype2/freetype/freetype.h:20:2:
#error “`ft2build.h’ hasn’t been included yet!”
/home/sye/Projects/OSDL/OSDL-0.3/src/conf/LOANI-installations/FreeType-2.1.7/include/freetype2/freetype/freetype.h:21:2:
#error “Please always use macros to include FreeType header files.”
/home/sye/Projects/OSDL/OSDL-0.3/src/conf/LOANI-installations/FreeType-2.1.7/include/freetype2/freetype/freetype.h:22:2:
#error “Example:”
/home/sye/Projects/OSDL/OSDL-0.3/src/conf/LOANI-installations/FreeType-2.1.7/include/freetype2/freetype/freetype.h:23:2:
#error " #include <ft2build.h>"
/home/sye/Projects/OSDL/OSDL-0.3/src/conf/LOANI-installations/FreeType-2.1.7/include/freetype2/freetype/freetype.h:24:2:
#error " #include FT_FREETYPE_H"
make: *** [SDL_ttf.lo] Error 1

which can be solved by adding in SDL_ttf-2.0.6/SDL_ttf.c these two lines :

#include <ft2build.h>
#include FT_FREETYPE_H

just before

#include <freetype/freetype.h>
#include <freetype/ftoutln.h>
#include <freetype/ttnameid.h>
#include <freetype/internal/ftobjs.h>

Hope this helps,
kind regards,

Olivier.

I was having similar compilation problems with FreeType 2.1.8rc.
Adding the following didn’t solve my compilation problems with FreeType
2.1.8rc:
#include <ft2build.h>
#include FT_FREETYPE_H

In addition of adding those two lines above, I had to add the following
right below:
#include FT_OUTLINE_H
#include FT_TRUETYPE_IDS_H
#include <freetype/internal/ftobjs.h>

and remove the following:
#include <freetype/freetype.h>
#include <freetype/ftoutln.h>
#include <freetype/ttnameid.h>
#include <freetype/internal/ftobjs.h>

I think FreeType 2 encourages users to #include the special macros instead
of the header files. I had
problems with <freetype/internal/ftobjs.h> because apparently there was no
macro that would include
that file. I had to add that by itself. I haven’t tried 2.1.7, so 2.1.7
may not have the problem I had with
2.1.8rc1.

I am currently using redhat 9 too.

Wesley_________________________________________________________________
Stop worrying about overloading your inbox - get MSN Hotmail Extra Storage!
http://join.msn.com/?pgmarket=en-us&page=hotmail/es2&ST=1/go/onm00200362ave/direct/01/

Wesley Leong wrote:

I was having similar compilation problems with FreeType 2.1.8rc.
Adding the following didn’t solve my compilation problems with
FreeType 2.1.8rc:
#include <ft2build.h>
#include FT_FREETYPE_H

In addition of adding those two lines above, I had to add the
following right below:
#include FT_OUTLINE_H
#include FT_TRUETYPE_IDS_H
#include <freetype/internal/ftobjs.h>

and remove the following:
#include <freetype/freetype.h>
#include <freetype/ftoutln.h>
#include <freetype/ttnameid.h>
#include <freetype/internal/ftobjs.h>

I think FreeType 2 encourages users to #include the special macros
instead of the header files. I had
problems with <freetype/internal/ftobjs.h> because apparently there
was no macro that would include
that file. I had to add that by itself. I haven’t tried 2.1.7, so
2.1.7 may not have the problem I had with
2.1.8rc1.

I am currently using redhat 9 too.

Wesley

To the best of my knowledge, Freetype 2.1.5 is the last known version of
Freetype to work seamlessly with SDL_ttf 2.0.6. When I tried with
2.1.7, I got some errors relating to how the code is used, probably
simiilar to what you have above but I didn’t investigate. So, I would
recommend compiling using Freetype 2.1.5 if you just want to get the
library compiled.

-TomT64