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:
[code]
curl -O http://mirror.its.uidaho.edu/pub/savannah/freetype/freetype-2.3.9.tar.bz2
[/code]
Next go ahead and unzip, you could always leave the archive there just in case:
[code]
tar -jxvf freetype-2.3.9.tar.bz2
[/code]
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:
[code]
nano freetype-2.3.9/include/freetype/config/ftconfig.h
nano freetype-2.3.9/builds/unix/ftconfig.in
[/code]
Press CTRL-W type ‘asm’ and press ENTER
wrap ‘asm’ with 2 underscores on both sides so it looks like this:
[code]
__asm__
[/code]
Press CTRL-X press ‘y’ for yes then press ENTER to save the file.
Jump into the freetype directory:
[code]
cd freetype-2.3.9
[/code]
Run this configure command:
[code]
./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"
[/code]
Then just run make
[code]
make
[/code]
Your new library for the iPhone device will be in:
[code]
freetype-2.3.9/objs/.libs/
[/code]
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



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
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.
Oh very cool, thanks
Is it also both the device and simulator libraries, and for version 2.2?
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.
Do you have a sample code using the generated library? Can you post it?
Hello,
just wondering if you have heard of Sox sound exchange?
I was wondering if this can be modified to work with IOS? Your thoughts….
As, if you think it’s possible then we’ll try to create .a file for all targets…
Thanks
Noel
You should look at the README in the SourceForge Project for Sox, it makes mention all of the libraries that you need to build Sox on OSX. All these libraries would also need to be compiled for the iOS before you can compile Sox… I’ll list them here:
Ogg Vorbis – http://www.vorbis.com
FLAC – http://flac.sourceforge.net
libsndfile – http://www.mega-nerd.com/libsndfile
WavPack – http://www.wavpack.com
PNG – http://www.libpng.org/pub/png
Also there may be some problems if you are trying to decode or encode MP3s since there are patent restrictions:
http://en.wikipedia.org/wiki/MP3#Licensing_and_patent_issues
Have you considered using the audio libraries that Apple ships with the iOS? Maybe they already provide the functionality that you need. Or one of the above libraries could be simpler to port or may already be ported to the iOS.
Let me know if that is helpful.
I could supply some sample code for using freetype2 in opengl, for example. The thing is, is johndoe@yahoo.com your real email address? Please use a valid email so you can at least be notified if I post this information
While i’m following your guidance,to “Jump into the freetype directory”,
I have got the following ERROR as follows :
configure: WARNING: If you wanted to set the –build type, don’t use –host.
If a cross compiler is detected then cross compile mode will be used.
checking build system type… i386-apple-darwin10.7.0
checking host system type… arm-apple-darwin
checking for arm-apple-darwin-gcc… /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1
checking for C compiler default output file name…
configure: error: in `/Users/igate1/freetype-2.3.9/builds/unix’:
configure: error: C compiler cannot create executables
See `config.log’ for more details.
make: *** [setup] Error 77