为iPhone SDK编译Freetype(XCode)

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

我有; 这篇博文有很大帮助:

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

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

理想情况下,您将需要使用最新工具进行构建,并且在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 

使用Freetype附带的configure脚本。

 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”工具将库合并到一个多架构库中。