SDL_ttf linking error using TTF_GetFontKerning among others

I am having trouble linking SDL_ttf against a project I am developing on Mac OS X Snow Leopard. I am compiling SDL_ttf from source because I implemented my own function for getting the kerning between two characters in the library’s source code (I am making my own kerning-accurate glyph management system for a game). For some reason, even when I declare the function like I’m supposed to:

Code:
extern DECLSPEC int SDLCALL TTF_GetKerningBetween(const TTF_Font *font, Uint16 previous, Uint16 next);

Xcode has trouble linking my game with SDL_ttf, saying that the symbol isn’t found. It also does this with TTF_GetFontKerning and TTF_GlyphIsProvided, two other functions that I need. I am compiling in Xcode 3.2 using 10.4 as my base SDK, “Development” configuration, “Framework” target, and x86_64 architecture.

What could possibly be causing this problem? How are these functions (which are declared in SDL_ttf.c) not getting compiled in?

For reference, here’s my TTF_GetKerningBetween function. Hope I did that right.

Code:
int TTF_GetKerningBetween(const TTF_Font *font, Uint16 previous, Uint16 next)
{
int kerning = 0;
FT_Bool use_kerning;
FT_UInt left, right;
FT_Vector delta;
FT_Error err;

use_kerning = TTF_GetFontKerning( font );
left = FT_Get_Char_Index( font->face, (FT_ULong)previous );
right = FT_Get_Char_Index( font->face, (FT_ULong)next );

if( use_kerning == 1 )
{
	err = FT_Get_Kerning( font->face, left, right, ft_kerning_default, &delta );
	if( err == -1 )
		TTF_SetError( "Error getting kerning metrics." );
	else
		kerning = (int)delta.x >> 6;
}
return kerning;

}

-Morgan[/code]

Make sure you don’t have an old SDL_ttf framework installed anywhere, like
/Library/Frameworks or ~/Library/FrameworksOn Sun, Oct 11, 2009 at 10:33 AM, maclover201 wrote:

I am having trouble linking SDL_ttf against a project I am developing on
Mac OS X Snow Leopard. I am compiling SDL_ttf from source because I
implemented my own function for getting the kerning between two characters
in the library’s source code (I am making my own kerning-accurate glyph
management system for a game). For some reason, even when I declare the
function like I’m supposed to:

Code:

extern DECLSPEC int SDLCALL TTF_GetKerningBetween(const TTF_Font *font,
Uint16 previous, Uint16 next);

Xcode has trouble linking my game with SDL_ttf, saying that the symbol
isn’t found. It also does this with TTF_GetFontKerning and
TTF_GlyphIsProvided, two other functions that I need. I am compiling in
Xcode 3.2 using 10.4 as my base SDK, “Development” configuration,
“Framework” target, and x86_64 architecture.

What could possibly be causing this problem? How are these functions (which
are declared in SDL_ttf.c) not getting compiled in?

For reference, here’s my TTF_GetKerningBetween function. Hope I did that
right.

Code:

int TTF_GetKerningBetween(const TTF_Font *font, Uint16 previous, Uint16
next)
{
int kerning = 0;
FT_Bool use_kerning;
FT_UInt left, right;
FT_Vector delta;
FT_Error err;

use_kerning = TTF_GetFontKerning( font );
left = FT_Get_Char_Index( font->face, (FT_ULong)previous );
right = FT_Get_Char_Index( font->face, (FT_ULong)next );

if( use_kerning == 1 )
{
err = FT_Get_Kerning( font->face, left, right, ft_kerning_default,
&delta );
if( err == -1 )
TTF_SetError( “Error getting kerning metrics.” );
else
kerning = (int)delta.x >> 6;
}
return kerning;
}

-Morgan[/code]


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC

Already checked; the newest version is in /Library/Frameworks. I opened it with a hex editor and those symbols are obviously there and aren’t mangled, so what could be causing it?

The exact error is something like _TTF_GetKerningBetween referenced from int rKerning::GetKerning(char, char) (where GetKerning is obviously the function in my game). But yes, _TTF_GetKerningBetween and those other troublesome functions are compiled in.

I wonder if this would have anything to do with a messed up linking map?

I think I know what the problem is. We have an old export file
(exports/SDL_ttf.x I think inside the Xcode folder somewhere) that we
used to control the visibility of the symbols. It hasn’t been updated
in forever. If there are new functions, then they won’t get exported
to the library.

For some reason, I thought we removed these. I guess not. Anyway, now
that gcc 4.0 is our new baseline for Mac, the proper fix is to enable
the gcc visibility attributes and delete the exports file.

I’ll try to put a formal fix together. Meanwhile, if you can test this
and report if this is indeed the problem, that would be helpful.

You can do one of several things.

  1. Inside the exports directory, there is a script that was used to
    generate the export file. Re-run the script to create an updated file
    and rebuild SDL_ttf.

  2. In the Xcode settings, disable/delete the export setting.

  3. Do #2 and then enable gcc_visibility_hidden=true (or something like that)

-EricOn 10/12/09, maclover201 wrote:

I wonder if this would have anything to do with a messed up linking map?

That fixed it. Thanks.