Problem compiling code with SDL_ttf

Any ideas on this will be very helpful. I’m having problems compiling
anything to use SDL_ttf. I’ve tried the same things on Red Hat 7.3 and
8.0 machines, both with the same set of SDL packages installed: I have
SDL 1.2.5, SDL_ttf 2.0.6, FreeType 2.1.2, and all the matching 'devel’
packages (all installed from rpms) on both machines. But when I try to
compile anything that uses the TTF functions, I get linker errors. For
example, compiling Patrick Kooman’s Sfont/Bfont utility
(http://www.2dgame-tutorial.com/sdl/fontbuilder/fontbuilder.c) with the
compiler flags and libs from sdl-config, gives this:

gcc fontbuilder.c -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread -I/usr/include/SDL -D_REENTRANT
/tmp/cc5BwFjo.o: In function CreateFontSurface': /tmp/cc5BwFjo.o(.text+0x75): undefined reference toTTF_Init’
/tmp/cc5BwFjo.o(.text+0xb8): undefined reference to TTF_OpenFont' /tmp/cc5BwFjo.o(.text+0x109): undefined reference toTTF_SetFontStyle’
/tmp/cc5BwFjo.o(.text+0x16a): undefined reference to TTF_RenderText_Shaded' /tmp/cc5BwFjo.o(.text+0x1d7): undefined reference toTTF_CloseFont’
/tmp/cc5BwFjo.o(.text+0x1df): undefined reference to TTF_Quit' /tmp/cc5BwFjo.o(.text+0x228): undefined reference toTTF_CloseFont’
/tmp/cc5BwFjo.o(.text+0x230): undefined reference to `TTF_Quit’
collect2: ld returned 1 exit status

I have run ‘ldconfig’ a few times since those packages were installed on
each machine, so I don’t think that’s a problem. What libraries would
those functions require that wouldn’t come with SDL and SDL_ttf, and how
would I go about getting/updating them?

Thanks,
Ryan

Ryan: Looks like you are not linking your program with the SDL_ttf library.
Try adding the parameter -lSDL_ttf to the compiler, after the -lSDL
parameter. Something like this may work:

gcc
fontbuilder.c -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread -lSDL_ttf -I/us
r/include/SDL -D_REENTRANT

Alejandro.> ----- Original Message -----

From: ryanh@uidaho.edu (Ryan Hanlon)
To:
Sent: Thursday, May 15, 2003 8:16 PM
Subject: [SDL] Problem compiling code with SDL_ttf

Any ideas on this will be very helpful. I’m having problems compiling
anything to use SDL_ttf. I’ve tried the same things on Red Hat 7.3 and
8.0 machines, both with the same set of SDL packages installed: I have
SDL 1.2.5, SDL_ttf 2.0.6, FreeType 2.1.2, and all the matching 'devel’
packages (all installed from rpms) on both machines. But when I try to
compile anything that uses the TTF functions, I get linker errors. For
example, compiling Patrick Kooman’s Sfont/Bfont utility
(http://www.2dgame-tutorial.com/sdl/fontbuilder/fontbuilder.c) with the
compiler flags and libs from sdl-config, gives this:

gcc
fontbuilder.c -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread -I/usr/include/
SDL -D_REENTRANT
/tmp/cc5BwFjo.o: In function CreateFontSurface': /tmp/cc5BwFjo.o(.text+0x75): undefined reference toTTF_Init’
/tmp/cc5BwFjo.o(.text+0xb8): undefined reference to TTF_OpenFont' /tmp/cc5BwFjo.o(.text+0x109): undefined reference toTTF_SetFontStyle’
/tmp/cc5BwFjo.o(.text+0x16a): undefined reference to
TTF_RenderText_Shaded' /tmp/cc5BwFjo.o(.text+0x1d7): undefined reference toTTF_CloseFont’
/tmp/cc5BwFjo.o(.text+0x1df): undefined reference to TTF_Quit' /tmp/cc5BwFjo.o(.text+0x228): undefined reference toTTF_CloseFont’
/tmp/cc5BwFjo.o(.text+0x230): undefined reference to `TTF_Quit’
collect2: ld returned 1 exit status

I have run ‘ldconfig’ a few times since those packages were installed on
each machine, so I don’t think that’s a problem. What libraries would
those functions require that wouldn’t come with SDL and SDL_ttf, and how
would I go about getting/updating them?

Thanks,
Ryan


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Better idea is:

gcc file.c -o executable sdl-config --cflags --libs -lSDL_ttf

Run “sdl-config” ( without the quotes ), this script will automagically add
the correct flags for you to link against the base SDL library, to find out
what other options are available. Also notice the ` it is not a quotation
mark rather it is the the character character generated when you press the ~
key minus the shift modifier.

Good Luck,


Juan D. Espinoza
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)

iD8DBQE+w+nguAPGC4EGcKkRAtkNAJ4+iJWc0NoyBBn23cW4XS0hknG6QACeOhgY
FOqkVH+0bxQSlwn1seOk7bY=
=0hHa
-----END PGP SIGNATURE-----