Compiling FreeType for iPhone?

Tom89 picture Tom89 · Jun 21, 2011 · Viewed 8.4k times · Source

I'm using FreeType on Windows, Linux and OSX without a single problem, and now I was to port my tech to IOS... And I can't find a way to have FreeType compiled for it.

At first I tried to drop every FT file into my project, but that clearly didn't work.

Then I tried to make a static library following this tutorial here. While I can't test if it worked for the arm target, it doesn't work for the simulator target.

When trying to link the built library into XCode it says "libfreetype-simulator.a, file was built for archive which is not the architecture being linked (i386)" and that's ok because the command "lipo -info libfreetype-simulator.a" tells me that the file was built for x86_64. I tried configuring it with "./configure --i386-apple-darwin", here's the log. But still, the resulting arch was x86_64.

How in the world can I build freetype for i386, iphone simulator? I really have no clues.

Answer

robbie_c picture robbie_c · May 29, 2013

I used the link in cxa's answer. However it is very out of date, and my configure line did not fit in a comment. For armv7, compiling with the 6.1 SDK, with a minimum version of 5.1, without bzip2, you want something like:

./configure '--without-bzip2' '--prefix=/usr/local/iphone' '--host=arm-apple-darwin' '--enable-static=yes' '--enable-shared=no' 'CC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' 'CFLAGS=-arch armv7 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=5.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/include/libxml2/ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/' 'AR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar' 'LDFLAGS=-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/ -miphoneos-version-min=5.1'

Note the lack of -mdynamic-no-pic which would otherwise produce a linker warning, and a warning email from Apple, if left in. Also note that various pathnames have changed.