`
modabobo
  • 浏览: 508896 次
文章分类
社区版块
存档分类
最新评论

ios编译libfreetype,并适应armv7,armv7s,arm64

 
阅读更多

在github里看到人人网发布的一个CCHtmlLabel的RichText控件,可以显示复杂的html结构的富文本,配置好之后发现在模拟器上面能顺利跑起来,但在真机上却编译失败。

看error log的意思是指没有armv7s的slice,再看了一下CCHtmlLabel所用的libfreetype库,是2011年编译的,有点旧,当时iphone4s才刚出呢,当然没有armv7s了。

于是到SourceForge下载了freetype的源代码,编译成lib后再替换原来的libfreetype.a,再次用Xcode编译整个游戏项目,发现还是有个linker的错误:undefined reference to `BZ2_bzDecompressInit'

这个简单,在xcode里添加对libbz2.1.0.dylib的引用即可。

有需要的请到这里下载:http://download.csdn.net/detail/visualcatsharp/7076545


下面再记录一下编译的过程

mkdir /var/tmp/build-armv7


./configure CFLAGS="-arch i386"
make
cp objs/.libs/libfreetype.a libfreetype-i386.a


./configure CFLAGS="-arch x86_64";make clean;make
cp objs/.libs/libfreetype.a libfreetype-x86_64.a


make clean
./configure --prefix=/var/tmp/build-armv7 --host=arm-apple-darwin --enable-static=yes --enable-shared=no CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc CFLAGS="-arch armv7 -pipe -std=c99 -Wno-extended-offsetof -Wno-trigraphs -fpascal-strings -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=4.2 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk" AR=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar LDFLAGS="-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -miphoneos-version-min=4.2"
make
cp objs/.libs/libfreetype.a libfreetype-arm7.a


make clean
./configure --prefix=/var/tmp/build-armv7 --host=arm-apple-darwin --enable-static=yes --enable-shared=no CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc CFLAGS="-arch armv7s -pipe -std=c99 -Wno-extended-offsetof -Wno-trigraphs -fpascal-strings -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=4.2 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk" AR=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar LDFLAGS="-arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -miphoneos-version-min=4.2"
make
cp objs/.libs/libfreetype.a libfreetype-arm7s.a


make clean
./configure --prefix=/var/tmp/build-armv7 --host=arm-apple-darwin --enable-static=yes --enable-shared=no CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc CFLAGS="-arch arm64 -pipe -std=c99 -Wno-extended-offsetof -Wno-trigraphs -fpascal-strings -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=6.0 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk" AR=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar LDFLAGS="-arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -miphoneos-version-min=6.0"
make clean; make
cp objs/.libs/libfreetype.a libfreetype-arm64.a


lipo -create -output libfreetype.a libfreetype-i386.a libfreetype-x86_64.a libfreetype-arm7.a libfreetype-arm7s.a libfreetype-arm64.a
lipo -info libfreetype.a

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics