转自:http://blog.csdn.net/zhu410289616/article/details/29269937
mp3转码静态库libmp3lame.a,成功加入arm64支持后,
顺便把之前记录的二维码静态库libzbar.a也做一个整理。
从网上下载别人支持不够全面的静态库,查了下分离和合并静态库的方法,整理如下:
1. 得到两个支持部分cpu架构的静态库,放在同一个目录下,libzbar-i386-armv6-armv7.a, libzbar-armv7-armv7s-x86_64-arm64.a
2. 两个库都支持armv7架构,直接用lipo -create libzbar* -output libzar.a 命令会失败,需要先分离出i386, armv6,然后再继续合并
3. 先从libzbar-i386-armv6-armv7.a种分离出i386架构(这个只要一个命令得到结果),命令如下:
shutekiMacBook-Pro:libzbar pig$ lipo -extract_family i386 -output libzbar-i386.a libzbar-i386-armv6-armv7.a
shutekiMacBook-Pro:libzbar pig$ ls -lrt
total 19608
-rw-r--r-- 1 pig staff 3038988 6 7 23:27 libzbar-i386-armv6-armv7.a
-rw-r--r-- 1 pig staff 4962816 6 7 23:28 libzbar-armv7-armv7s-x86_64-arm64.a
-rw-r--r-- 1 pig staff 993000 6 7 23:33 libzbar-armv7.a
-rw-r--r-- 1 pig staff 1037504 6 7 23:37 libzbar-i386.a
shutekiMacBook-Pro:libzbar pig$ lipo -info libzbar-i386.a
input file libzbar-i386.a is not a fat file
Non-fat file: libzbar-i386.a is architecture: i386
shutekiMacBook-Pro:libzbar pig$
4. 从libzbar-i386-armv6-armv7.a种分离出armv6架构(这个需要多次分离),命令如下:
shutekiMacBook-Pro:libzbar pig$ lipo -extract_family armv6 -output libzbar-armv6-armv7.a libzbar-i386-armv6-armv7.a
shutekiMacBook-Pro:libzbar pig$
shutekiMacBook-Pro:libzbar pig$ ls -lrt
total 23520
-rw-r--r-- 1 pig staff 3038988 6 7 23:27 libzbar-i386-armv6-armv7.a
-rw-r--r-- 1 pig staff 4962816 6 7 23:28 libzbar-armv7-armv7s-x86_64-arm64.a
-rw-r--r-- 1 pig staff 1037504 6 7 23:37 libzbar-i386.a
-rw-r--r-- 1 pig staff 2001464 6 7 23:38 libzbar-armv6-armv7.a
shutekiMacBook-Pro:libzbar pig$
shutekiMacBook-Pro:libzbar pig$ lipo -info libzbar-armv6-armv7.a (这里查看静态库都信息,实际分离出来的.a文件同时包含armv6和armv7,所以我命名中也注意标注了)
Architectures in the fat file: libzbar-armv6.a are: armv6 armv7
shutekiMacBook-Pro:libzbar pig$
5. 在步骤4的基础上,从libzbar-armv6-armv7.a种分离出armv6,命令如下:
shutekiMacBook-Pro:libzbar pig$ lipo libzbar-armv6-armv7.a -thin armv6 -output libzbar-armv6.a
shutekiMacBook-Pro:libzbar pig$
shutekiMacBook-Pro:libzbar pig$ ls -lrt
total 21584
-rw-r--r-- 1 pig staff 3038988 6 7 23:27 libzbar-i386-armv6-armv7.a
-rw-r--r-- 1 pig staff 4962816 6 7 23:28 libzbar-armv7-armv7s-x86_64-arm64.a
-rw-r--r-- 1 pig staff 993000 6 7 23:33 libzbar-armv6-armv7.a
-rw-r--r-- 1 pig staff 1037504 6 7 23:37 libzbar-i386.a
-rw-r--r-- 1 pig staff 1008416 6 7 23:38 libzbar-armv6.a
6. 同步骤5,从libzbar-armv6-armv7.a种分离出armv7,命令如下:
shutekiMacBook-Pro:libzbar pig$ lipo libzbar-armv6-armv7.a -thin armv7 -output libzbar-armv7.a
7. 合并i386,armv6和libzbar-armv7-armv7s-x86_64-arm64.a(为了方便执行create命令,我已经把不需要的.a文件做了重命名),合并命令如下:
shutekiMacBook-Pro:libzbar pig$ ls -lrt
total 21584
-rw-r--r-- 1 pig staff 3038988 6 7 23:27 src-libzbar-i386-armv6-armv7.a
-rw-r--r-- 1 pig staff 4962816 6 7 23:28 libzbar-armv7-armv7s-x86_64-arm64.a
-rw-r--r-- 1 pig staff 993000 6 7 23:33 src-libzbar-armv7.a
-rw-r--r-- 1 pig staff 1037504 6 7 23:37 libzbar-i386.a
-rw-r--r-- 1 pig staff 1008416 6 7 23:38 libzbar-armv6.a
shutekiMacBook-Pro:libzbar pig$
shutekiMacBook-Pro:libzbar pig$ lipo -create libzbar-* -output libzbar.a
8. 大功告成,赶紧查看下合并后的cpu架构支持:
shutekiMacBook-Pro:libzbar pig$ lipo -info libzbar.a
Architectures in the fat file: libzbar.a are: armv6 armv7 armv7s x86_64 i386 arm64
下载地址:http://download.csdn.net/detail/zhu410289616/7464153