Welcome to Theorian

Featured Post

Interview with Theorian President
This is a quick howto which will help you compile freetype2 for you to use in your iPhone/iTouch app or game. But first you should know that you can find the freetype2 libraries pre-compiled for...
Read More ...


Member Login

Sign Up Now!

Forgot Password !

New password will be e-mailed to you.

How to compile freetype2 for the iPhone

Easy AdSense by Unreal

This is a quick howto which will help you compile freetype2 for you to use in your iPhone/iTouch app or game. But first you should know that you can find the freetype2 libraries pre-compiled for the iPhone and iPhone simulators within in these openFramework zips. We use this in our iPhone game NanoMechs

But if you’d still like to compile your own, we want to get the latest freetype src:

curl -O http://mirror.its.uidaho.edu/pub/savannah/freetype/freetype-2.3.9.tar.bz2

Next go ahead and unzip, you could always leave the archive there just in case:

tar -jxvf freetype-2.3.9.tar.bz2

Now use your favorite text editor and jump into include/freetype/config/ftconfig.h and . then find and change the “asm” to “__asm__” in each file. You can do this in nano:

nano freetype-2.3.9/include/freetype/config/ftconfig.h
nano freetype-2.3.9/builds/unix/ftconfig.in

Press CTRL-W type ‘asm’ and press ENTER
wrap ‘asm’ with 2 underscores on both sides so it looks like this:

__asm__

Press CTRL-X press ‘y’ for yes then press ENTER to save the file.
Jump into the freetype directory:

cd freetype-2.3.9

Run this configure command:

./configure --prefix=/usr/local/iphone --host=arm-apple-darwin --enable-static=yes --enable-shared=no CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1 CFLAGS="-arch armv6 -pipe -mdynamic-no-pic -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=2.0 -gdwarf-2 -mthumb -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/include/libxml2 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk" CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar LDFLAGS="-arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk -Wl,-dead_strip -miphoneos-version-min=2.0"

Then just run make

make

Your new library for the iPhone device will be in:

freetype-2.3.9/objs/.libs/

note: This is not for the simulator and you will still need to get this into Xcode I’ll post more on this later or update this post.

Here are some related and essential websites on how to compile libraries for the iPhone: Robert Carlsen Compiling Libraries, Robert Carlsen Cross-Compiling and LateNightSoft Programming Tips

4 Responses to “How to compile freetype2 for the iPhone”

  1. Sean Murray says:

    Hi Theorian! I just received an update e-mail from the other gentleman’s blog that i posted to, about this update. I downloaded the openFrameworks file and got the freetype library ok. I was about to test it out when i noticed that it is 4.8 MB. That seems awfully high, as it’s almost half the size of a small iphone game O.o My friend who uses the PC version of library said his is ~860k. Is there a reason it’s so big? Thanks!

    Sean

  2. Right off the top of my head, the reason it is so big is because it is a static library and it has ARM and x86 compiled into it for both the iPhone and the simulator. But rest assured, when you use it in your app/game the entire library won’t be included. Build a sample project and give it a try. I’d be happy help more. I plan to either expand on this or add another post about bringing FreeType into your Xcode project.

  3. Sean Murray says:

    Oh very cool, thanks :-) Is it also both the device and simulator libraries, and for version 2.2?

  4. You are very welcome!

    Yes, because the library is built for ARM and x86 it will work with the device and simulator. Also, I’ve successfully built a project for OS 2.2 using this library.

Leave a Reply