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 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值