为iPhone SDK编译Freetype(XCode)

时间:2010-04-29 20:57:39

标签: iphone c xcode freetype

我想知道是否有人知道如何在iPhone SDK的XCode中配置FreeType。我一直在尝试没有成功。

3 个答案:

答案 0 :(得分:4)

理想情况下,您需要使用最新工具进行构建,并且自iOS 6.0 SDK发布以来,最低SDK版本为4.3,并且版本为armv7和armv7s。

这是我用来为iOS构建freetype 2.4.10的methid。从freetype 2.4.10源代码的根目录开始,执行:

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

接下来,清理构建目录,然后再为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

最后,将架构组合成一个二进制文件,并为第二个架构删除不必要的额外标头等(与第一个架构相同)。

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

答案 1 :(得分:1)

我有;这篇博文非常有帮助:

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

(另外,谷歌周围有很多例子可以做类似的事情。

答案 2 :(得分:1)

使用随Freetype提供的配置脚本。

mkdir install_dir

如果您正在为模拟器进行编译:

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

./configure --prefix=install_dir

如果您正在为设备进行编译:

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

然后

make
make install

现在,您将在'install_dir'中找到标题和库。

'make install'步骤很重要,因为configure会正确设置标题。您不能直接从源树中复制或使用它们。

您可以为每个平台(模拟器和设备)构建,然后使用'lipo'工具将库合并到一个多架构库中。