Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling FreeType for iPhone?

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.

like image 497
Tom89 Avatar asked Jun 21 '11 13:06

Tom89


2 Answers

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.

like image 84
robbie_c Avatar answered Oct 10 '22 21:10

robbie_c


I came across this project today while trying to compile FreeType for iOS: https://github.com/cdave1/freetype2-ios

Just download, open in xcode, and compile. :)

Hope this is helpful for anyone else trying to compile for iOS.

like image 20
wermy Avatar answered Oct 10 '22 21:10

wermy