为iPhone SDK (XCode)编译FreeType

3

我想知道有没有人知道如何在iPhone SDK中为XCode配置FreeType。我一直尝试着,但没有成功。

3个回答

4

理想情况下,您希望使用最新的工具进行构建。截至iOS 6.0 SDK发布时,最低SDK版本为4.3,并且需要为armv7和armv7s构建。

以下是我用于构建iOS的freetype 2.4.10的方法。从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

2
这正是我要找的东西。我按原样运行它,但它没有工作。我得到了错误:configure: error: expected an absolute directory name for --prefix: ./build-armv7。所以我把 --prefix 改成了 $PWD/build-armv7,然后运行命令,一切都正常了!太棒了! - ageektrapped

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”步骤非常重要,因为配置将正确设置头文件。您不能直接从源代码树中复制或直接使用它们。

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


1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接