我想知道有没有人知道如何在iPhone SDK中为XCode配置FreeType。我一直尝试着,但没有成功。
理想情况下,您希望使用最新的工具进行构建。截至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
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”工具将库组合成一个多架构库。
我有一个问题;这篇博客帖子对我帮助很大:
http://robertcarlsen.net/2009/03/25/openframeworks-iphone-libs-593
(此外,谷歌上有很多类似的示例可供参考。)
configure: error: expected an absolute directory name for --prefix: ./build-armv7
。所以我把--prefix
改成了$PWD/build-armv7
,然后运行命令,一切都正常了!太棒了! - ageektrapped