3

I was wondering if anyone knew how to configure FreeType in XCode for the iPhone SDK. I have been trying with no success.

3 Answers 3

4

Ideally you'll want to build using the latest tools, and as of the release of iOS 6.0 SDK, with a minimum SDK version of 4.3 and with builds for armv7 and armv7s.

Here is the methid I used to build freetype 2.4.10 for iOS. From the root of the freetype 2.4.10 source, do:

mkdir build-armv7

./configure --prefix=./build-armv7 --host=arm-apple-darwin --enable-static=yes --enable-shared=no \
CPPFLAGS="-arch armv7 -fpascal-strings -Os -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=4.3 -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/include/libxml2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk" \
CC=`xcrun -sdk iphoneos -find clang` \
CFLAGS="-arch armv7 -fpascal-strings -Os -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=4.3 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk" \
LD=`xcrun -sdk iphoneos -find ld` \
LDFLAGS="-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk -miphoneos-version-min=4.3" \
AR=`xcrun -sdk iphoneos -find ar`

make
make install

Next, clean the build directory, and build again for armv7s:

make clean
mkdir build-armv7s

./configure --prefix=./build-armv7s --host=arm-apple-darwin --enable-static=yes --enable-shared=no \
CPPFLAGS="-arch armv7s -fpascal-strings -Os -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=4.3 -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/include/libxml2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk" \
CC=`xcrun -sdk iphoneos -find clang` \
CFLAGS="-arch armv7s -fpascal-strings -Os -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=4.3 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk" \
LD=`xcrun -sdk iphoneos -find ld` \
LDFLAGS="-arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk -miphoneos-version-min=4.3" \
AR=`xcrun -sdk iphoneos -find ar`

make
make install

Finally, combine the architectures into a single binary, and remove the unnecessary extra headers etc. for the second architecture (which are identical to the first architecture).

xcrun -sdk iphoneos lipo -create -arch armv7 build-armv7/lib/libfreetype.a -arch armv7s build-armv7s/lib/libfreetype.a -output libfreetype_universal.a
rm -rf build-armv7s
mv -f libfreetype_universal.a build-armv7/lib/libfreetype.a
mv build-armv7 build
Sign up to request clarification or add additional context in comments.

1 Comment

This is EXACTLY what I'm looking for. I ran it as is, but it wasn't working. I got the error: configure: error: expected an absolute directory name for --prefix: ./build-armv7. So I changed --prefix to this: $PWD/build-armv7, ran the command and everything worked! Great stuff!
1

I have; this blog post helped immensely:

http://robertcarlsen.net/2009/03/25/openframeworks-iphone-libs-593

(Plus, there are lots of examples lying around google that do similar things.

Comments

1

Use the configure script supplied with Freetype.

mkdir install_dir

If you are compiling for the simulator:

export CFLAGS = "-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk"

./configure --prefix=install_dir

if you are compiling for a device:

export CFLAGS = "-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk"

./configure --prefix=install_dir --host=arm-apple-darwin

and then

make
make install

You will now find the headers and lib in 'install_dir'.

the 'make install' step is important, as configure will setup the headers correctly. You can't just copy or use them directly from the source tree.

You can build for each platform (simulator and device) and then combine the libs into one multi-architechture lib using the 'lipo' tool.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.