打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Building Free Type ForiOS

Building FreeType for iOS ?

The only dependencies libRocket has is on the FreeType library. The library has build configurations for most platforms, but unfortunately not iOS. This document describes how to build libfreetype.a as a universal binary for iOS and the Mac (i386, x86_64, arm6, arm7).

NOTE: You can download a prebuilt version of these libraries from the download section.

Download the Source ?

Download the latest freetype sourcecode from sourceforge.

Open a terminal and extract the archive:

$ tar -jxf libfreetype-2.4.2.tar.bz2$ cd libfreetype-2.4.2

Compiling the library ?

We have to compile the library four times, once for each architecture.

i386

$ ./configure CFLAGS="-arch i386"$ make

This forces configure to use the i386 architecture and build the library. The built library is located at objs/.libs/libfreetype.a. We copy this to our top level folder and build the next architecture.

$ cp objs/.libs/libfreetype.a libfreetype-i386.a

x86_64

Similar build setup for x86_64, notice the addition of make clean, we want to completely remove the i386 code.

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

arm6

Arm6 is used on iPhone 3G and earlier. There are quite a few arguments that need to be passed to configure to make it build for arm6. I'm going under the assumption that you're targeting iOS 3.2 using gcc-4.2 as your compiler. If this is not what you want, please update the arguments below accordingly.

$ ./configure --prefix=/usr/local/iphone --host=arm-apple-darwin --enable-static=yes --enable-shared=no CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2  CFLAGS="-arch armv6 -pipe -mdynamic-no-pic -std=c99 -Wno-trigraphs -fpascal-strings -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=3.2 -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk/usr/include/libxml2 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk" CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar LDFLAGS="-arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk -miphoneos-version-min=3.2"$ make clean;make$ cp objs/.libs/libfreetype.a libfreetype-arm6.a

arm7

Arm7 is used on iPhone 3GS and newer. We do the exact same options as above, but pass arm7 as the architecture (remember to update the CFLAGS and the LDFLAGS)

$ ./configure --prefix=/usr/local/iphone --host=arm-apple-darwin --enable-static=yes --enable-shared=no CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2  CFLAGS="-arch armv7 -pipe -mdynamic-no-pic -std=c99 -Wno-trigraphs -fpascal-strings -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=3.2 -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk/usr/include/libxml2 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk" CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar LDFLAGS="-arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk -miphoneos-version-min=3.2"$ make clean;make$ cp objs/.libs/libfreetype.a libfreetype-arm7.a

Bringing it all together as a universal library ?

We now have 4 individual libraries. To combine them into a single universal library use the lipo tool.

$ lipo -create -output libfreetype.a libfreetype-i386.a libfreetype-x86_64 libfreetype-arm6.a libfreetype-arm7.a

And thats it.

You can check which architectures are in a library with the -info argument.

$ lipo -info libfreetype.aArchitectures in the fat file: libfreetype.a are: armv6 armv7 i386 x86_64 
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
编译speex(i386、armv6、armv7、armv7s)方法【转】
以samba讲解如何交叉编译开源库用于iphone平台(续)
iOS安全攻防(十二):iOS7的动态库注入
升级Xcode 10 后报错问题记录(xcode 10 适配)
iOS openssl 移植
debugserver
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服