Error when cross-compiling SDL_ttf and Freetype

I make a simple project to test cross-compile Windows app on Mac.

This is the main.c

#include “SDL.h”
#include “SDL_ttf.h”

#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include FT_STROKER_H

const int WINDOW_WIDTH = 640;
const int WINDOW_HEIGHT = 480;
const char* WINDOW_TITLE = “SDL Start”;

int main(int argc, char *argv[])
{
SDL_Init( SDL_INIT_VIDEO );

SDL_Surface* screen = SDL_SetVideoMode( WINDOW_WIDTH, WINDOW_HEIGHT, 0,
                                       SDL_HWSURFACE | SDL_DOUBLEBUF );

TTF_Font *font = TTF_OpenFont("test.ttf", 18);

// FT_Library library;
// FT_Face face;
// const char * fname = “somefont”;
//
//
// if (FT_Init_FreeType( &library ))
// printf(“error init freetype”);
//
// if (FT_New_Face( library, fname, 0, &face ))
// printf(“error new face”);
//
// if(FT_Load_Glyph( face, FT_Get_Char_Index( face, ‘A’ ),
FT_LOAD_DEFAULT ))
// printf(“error load glyph”);
//
// FT_Glyph bitmap_glyph = NULL;
//
// FT_Stroker stroker;
// FT_Get_Glyph( face->glyph, &bitmap_glyph );
// int error = FT_Stroker_New( library, &stroker );

SDL_Event event;
printf("hello world.");

int gameRunning = 1;

while (gameRunning)
{
    if (SDL_PollEvent(&event))
    {
        if (event.type == SDL_QUIT)
        {
            gameRunning = 0;
        }
    }
}

SDL_Quit();

return 0;

}

The link command:

/Developer/Cocotron/1.0/Windows/i386/gcc-4.3.1/bin/i386-mingw32msvc-gcc
-arch i386
-L/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Development_using_10.4SDK_and_10.6SDK
-filelist
"/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Intermediates/SDL.build/Development_using_10.4SDK_and_10.6SDK/test-win32.build/Objects-normal/i386/test-win32.LinkFileList"
/Users/shinno/Library/Developer/Xcode/DerivedData/xign-ectoyemcfihayfhkbfsnwdgjwatz/Build/Products/Debug/libFreetype2-Win32.a
/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Release/libSDL_ttf-Win32.a
-lSDL-Win32 -lopengl32 -luuid -loleaut32 -lole32 -lgdi32 -lwinmm -lversion
-limm32 -o
/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Development_using_10.4SDK_and_10.6SDK/test-win32.exe

in brief

/i386-mingw32msvc-gcc -arch i386 [Filelist] -lSDL_ttf-Win32 -lSDL-Win32
-lFreetype2-Win32 out.exe

Now the problem:

When I comment the Freetype functions out like above, The SDL_ttf.c throw
"Undefined *FT_Get_Glyph" *error. When I remove the comment symbol, every
thing is ok.
The same thing also happen when I use SDL_image and libpng.

Can someone help?–

Best Regards

Xing Ye

I make a simple project to test cross-compile Windows app on Mac.

This is the main.c

#include “SDL.h”
#include “SDL_ttf.h”

#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include FT_STROKER_H

const int WINDOW_WIDTH = 640;
const int WINDOW_HEIGHT = 480;
const char* WINDOW_TITLE = “SDL Start”;

int main(int argc, char *argv[])
{
SDL_Init( SDL_INIT_VIDEO );

SDL_Surface* screen = SDL_SetVideoMode( WINDOW_WIDTH, WINDOW_HEIGHT, 0

,
SDL_HWSURFACE | SDL_DOUBLEBUF);

TTF_Font *font = TTF_OpenFont("test.ttf", 18);

// FT_Library library;
// FT_Face face;
// const char * fname = “somefont”;
//
//
// if (FT_Init_FreeType( &library ))
// printf(“error init freetype”);
//
// if (FT_New_Face( library, fname, 0, &face ))
// printf(“error new face”);
//
// if(FT_Load_Glyph( face, FT_Get_Char_Index( face, ‘A’ ),
FT_LOAD_DEFAULT ))
// printf(“error load glyph”);
//
// FT_Glyph bitmap_glyph = NULL;
//
// FT_Stroker stroker;
// FT_Get_Glyph( face->glyph, &bitmap_glyph );
// int error = FT_Stroker_New( library, &stroker );

SDL_Event event;
printf("hello world.");

int gameRunning = 1;

while (gameRunning)
{
    if (SDL_PollEvent(&event))
    {
        if (event.type == SDL_QUIT)
        {
            gameRunning = 0;
        }
    }
}

SDL_Quit();

return 0;

}

The link command:

/Developer/Cocotron/1.0/Windows/i386/gcc-4.3.1/bin/i386-mingw32msvc-gcc

-arch i386
-L/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Development_using_10.4SDK_and_10.6SDK
-filelist
"/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Intermediates/SDL.build/Development_using_10.4SDK_and_10.6SDK/test-win32.build/Objects-normal/i386/test-win32.LinkFileList"
/Users/shinno/Library/Developer/Xcode/DerivedData/xign-ectoyemcfihayfhkbfsnwdgjwatz/Build/Products/Debug/libFreetype2-Win32.a
/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Release/libSDL_ttf-Win32.a
-lSDL-Win32 -lopengl32 -luuid -loleaut32 -lole32 -lgdi32 -lwinmm -lversion
-limm32 -o
/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Development_using_10.4SDK_and_10.6SDK/test-win32.exe

in brief

/i386-mingw32msvc-gcc -arch i386 [Filelist] -lSDL_ttf-Win32 -lSDL-Win32

-lFreetype2-Win32 out.exe

Now the problem:

When I comment the Freetype functions out like above, The SDL_ttf.c throw
"Undefined *FT_Get_Glyph" *error. When I remove the comment symbol, every
thing is ok.
The same thing also happen when I use SDL_image and libpng.

Can someone help?–

Best Regards

Xing Ye

Link commands and errors

Ld
/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Development_using_10.4SDK_and_10.6SDK/test-win32.exe
normal i386
cd /Users/shinno/workspace/xign2/jni/SDL/Xcode/SDL

/Developer/Cocotron/1.0/Windows/i386/gcc-4.3.1/bin/i386-mingw32msvc-gcc
-arch i386 -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
-L/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Development_using_10.4SDK_and_10.6SDK
-L/Users/shinno/workspace/xign2/jni/SDL/Xcode/SDL/…/…/…/…/…/…/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Release
-F/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Development_using_10.4SDK_and_10.6SDK
-filelist
/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Intermediates/SDL.build/Development_using_10.4SDK_and_10.6SDK/test-win32.build/Objects-normal/i386/test-win32.LinkFileList
/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Release/libFreetype2-Win32.a
/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Release/libSDL_ttf-Win32.a
-lSDL-Win32 -lopengl32 -luuid -loleaut32 -lole32 -lgdi32 -lwinmm -lversion
-limm32 -o
/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Development_using_10.4SDK_and_10.6SDK/test-win32.exe
/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Release/libSDL_ttf-Win32.a(SDL_ttf.o):
In function TTF_GetFontKerningSize': /Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/../SDL_ttf.c:2094: undefined reference to_FT_Get_Kerning’
/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Release/libSDL_ttf-Win32.a(SDL_ttf.o):
In function TTF_Quit': /Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/../SDL_ttf.c:2081: undefined reference to_FT_Done_FreeType’
/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Release/libSDL_ttf-Win32.a(SDL_ttf.o):
In function Load_Glyph': /Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/../SDL_ttf.c:595: undefined reference to_FT_Get_Char_Index’
/Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/…/SDL_ttf.c:597:
undefined reference to _FT_Load_Glyph' /Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/../SDL_ttf.c:659: undefined reference to_FT_Outline_Transform’
/Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/…/SDL_ttf.c:665:
undefined reference to _FT_Get_Glyph' /Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/../SDL_ttf.c:666: undefined reference to_FT_Stroker_New’
/Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/…/SDL_ttf.c:670:
undefined reference to _FT_Stroker_Set' /Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/../SDL_ttf.c:671: undefined reference to_FT_Glyph_Stroke’
/Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/…/SDL_ttf.c:672:
undefined reference to _FT_Stroker_Done' /Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/../SDL_ttf.c:674: undefined reference to_FT_Glyph_To_Bitmap’
/Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/…/SDL_ttf.c:676:
undefined reference to _FT_Done_Glyph' /Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/../SDL_ttf.c:682: undefined reference to_FT_Render_Glyph’
/Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/…/SDL_ttf.c:883:
undefined reference to _FT_Done_Glyph' /Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Release/libSDL_ttf-Win32.a(SDL_ttf.o): In functionTTF_SizeUNICODE’:
/Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/…/SDL_ttf.c:1169:
undefined reference to _FT_Get_Kerning' /Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Release/libSDL_ttf-Win32.a(SDL_ttf.o): In functionTTF_RenderUNICODE_Blended’:
/Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/…/SDL_ttf.c:1907:
undefined reference to _FT_Get_Kerning' /Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Release/libSDL_ttf-Win32.a(SDL_ttf.o): In functionTTF_RenderUNICODE_Shaded’:
/Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/…/SDL_ttf.c:1650:
undefined reference to _FT_Get_Kerning' /Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Release/libSDL_ttf-Win32.a(SDL_ttf.o): In functionTTF_RenderUNICODE_Solid’:
/Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/…/SDL_ttf.c:1385:
undefined reference to _FT_Get_Kerning' /Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Release/libSDL_ttf-Win32.a(SDL_ttf.o): In functionTTF_CloseFont’:
/Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/…/SDL_ttf.c:915:
undefined reference to _FT_Done_Face' /Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Release/libSDL_ttf-Win32.a(SDL_ttf.o): In functionTTF_OpenFontIndexRW’:
/Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/…/SDL_ttf.c:426:
undefined reference to _FT_Open_Face' /Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/../SDL_ttf.c:448: undefined reference to_FT_Set_Charmap’
/Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/…/SDL_ttf.c:455:
undefined reference to _FT_Set_Char_Size' /Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/../SDL_ttf.c:464: undefined reference to_FT_MulFix’
/Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/…/SDL_ttf.c:465:
undefined reference to _FT_MulFix' /Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/../SDL_ttf.c:467: undefined reference to_FT_MulFix’
/Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/…/SDL_ttf.c:468:
undefined reference to _FT_MulFix' /Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/../SDL_ttf.c:469: undefined reference to_FT_MulFix’
/Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/…/SDL_ttf.c:479:
undefined reference to _FT_Set_Pixel_Sizes' /Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Release/libSDL_ttf-Win32.a(SDL_ttf.o): In functionTTF_Init’:
/Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/…/SDL_ttf.c:347:
undefined reference to _FT_Init_FreeType' /Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Release/libSDL_ttf-Win32.a(SDL_ttf.o): In functionTTF_GlyphIsProvided’:
/Users/shinno/workspace/xign2/jni/SDL_ttf/Xcode/…/SDL_ttf.c:1020:
undefined reference to `_FT_Get_Char_Index’
collect2: ld returned 1 exit status

Best RegardsOn Fri, Sep 21, 2012 at 10:44 AM, Ye Xing <@Ye_Xing> wrote:

I make a simple project to test cross-compile Windows app on Mac.

This is the main.c

#include “SDL.h”
#include “SDL_ttf.h”

#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include FT_STROKER_H

const int WINDOW_WIDTH = 640;
const int WINDOW_HEIGHT = 480;
const char* WINDOW_TITLE = “SDL Start”;

int main(int argc, char *argv[])
{
SDL_Init( SDL_INIT_VIDEO );

SDL_Surface* screen = SDL_SetVideoMode( WINDOW_WIDTH, WINDOW_HEIGHT,

0,
SDL_HWSURFACE | SDL_DOUBLEBUF);

TTF_Font *font = TTF_OpenFont("test.ttf", 18);

// FT_Library library;
// FT_Face face;
// const char * fname = “somefont”;
//
//
// if (FT_Init_FreeType( &library ))
// printf(“error init freetype”);
//
// if (FT_New_Face( library, fname, 0, &face ))
// printf(“error new face”);
//
// if(FT_Load_Glyph( face, FT_Get_Char_Index( face, ‘A’ ),
FT_LOAD_DEFAULT ))
// printf(“error load glyph”);
//
// FT_Glyph bitmap_glyph = NULL;
//
// FT_Stroker stroker;
// FT_Get_Glyph( face->glyph, &bitmap_glyph );
// int error = FT_Stroker_New( library, &stroker );

SDL_Event event;
printf("hello world.");

int gameRunning = 1;

while (gameRunning)
{
    if (SDL_PollEvent(&event))
    {
        if (event.type == SDL_QUIT)
        {
            gameRunning = 0;
        }
    }
}

SDL_Quit();

return 0;

}

The link command:

/Developer/Cocotron/1.0/Windows/i386/gcc-4.3.1/bin/i386-mingw32msvc-gcc

-arch i386
-L/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Development_using_10.4SDK_and_10.6SDK
-filelist
"/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Intermediates/SDL.build/Development_using_10.4SDK_and_10.6SDK/test-win32.build/Objects-normal/i386/test-win32.LinkFileList"
/Users/shinno/Library/Developer/Xcode/DerivedData/xign-ectoyemcfihayfhkbfsnwdgjwatz/Build/Products/Debug/libFreetype2-Win32.a
/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Release/libSDL_ttf-Win32.a
-lSDL-Win32 -lopengl32 -luuid -loleaut32 -lole32 -lgdi32 -lwinmm -lversion
-limm32 -o
/Users/shinno/Library/Developer/Xcode/DerivedData/SDL-hbbipiabkoxqhscyceucbktuavaw/Build/Products/Development_using_10.4SDK_and_10.6SDK/test-win32.exe

in brief

/i386-mingw32msvc-gcc -arch i386 [Filelist] -lSDL_ttf-Win32 -lSDL-Win32

-lFreetype2-Win32 out.exe

Now the problem:

When I comment the Freetype functions out like above, The SDL_ttf.c throw
"Undefined *FT_Get_Glyph" *error. When I remove the comment symbol, every
thing is ok.
The same thing also happen when I use SDL_image and libpng.

Can someone help?

Best Regards

Xing Ye