如何判断一个静态库(.a文件)所支持的架构(平台)

问:

How do I determine the target architecture of static library (.a) on Mac OS X?

I'm interested in verifying if a given iPhone static library has been built for ARM or Intel.

Its more curiosity than anything. Is there some kind of Mac OS X or BSD specific tool to do this? Thispost gives an example in Linux.


方法1:

file will probably tell you. otool certainly should be able to. But I'd try file first, e.g.

logan:/Users/logan% file d2
d2: Mach-O executable ppc

Example with archive:

logan:/Users/logan% file /usr/lib/libMallocDebug.a
/usr/lib/libMallocDebug.a: Mach-O universal binary with 2 architectures
/usr/lib/libMallocDebug.a (for architecture i386):      current ar archive random library
/usr/lib/libMallocDebug.a (for architecture ppc):       current ar archive

方法2:

Another option is lipo, it's output is brief and more readable that otool's.

Example:

% lipo -info /usr/lib/libiodbc.a 
Architectures in the fat file: /usr/lib/libiodbc.a are: x86_64 i386 ppc
% lipo -info libnonfatarchive.a
input file libnonfatarchive.a is not a fat file
Non-fat file: libnonfatarchive.a is architecture: i386
%


方法3:

As mentioned earlier, file does not always work. otool -hv is probably the closest thing that is guaranteed to work - it gives architecture information for every single object file in the library.

Example:

% otool -hv /sw/lib/libfftw3.a
Archive : /sw/lib/libfftw3.a
/sw/lib/libfftw3.a(align.o):
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
MH_MAGIC_64  X86_64        ALL  0x00      OBJECT     3        336 SUBSECTIONS_VIA_SYMBOLS
/sw/lib/libfftw3.a(alloc.o):
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
MH_MAGIC_64  X86_64        ALL  0x00      OBJECT     3        416 SUBSECTIONS_VIA_SYMBOLS


Hadoop2.2.0 native lib 直接替换掉 2.2.0 发布包里面的nativeIO ,配置好环境变量就可以了 东西虽然小,但是却费了不少功夫,主要是由于本地网络控制,不允许上网。安装各种软件就费了很大劲,软件之间的依赖也很让人头痛, 希望能帮到有需要的兄弟姐妹。。。! 包含的文件: ~/hadoop/hadoop-2.2.0/lib/native> ll 总计 1540 -rw-r--r-- 1 weblogic users 734402 04-15 10:22 libhadoop.a -rwxr-xr-x 1 weblogic users 412856 04-15 10:22 libhadoop.so -rwxr-xr-x 1 weblogic users 412856 04-15 10:22 libhadoop.so.1.0.0 ~/hadoop/hadoop-2.2.0/lib/native> file * libhadoop.a: current ar archive libhadoop.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped libhadoop.so.1.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped 下面是查询的详细OS版本信息 #uname -a Linux F23-B4-E2-B3 2.6.32.12-0.7-default #1 SMP 2010-05-20 11:14:20 +0200 x86_64 x86_64 x86_64 GNU/Linux # lsb_release -a LSB Version: core-2.0-noarch:core-3.2-noarch:core-4.0-noarch:core-2.0-x86_64:core-3.2-x86_64:core-4.0-x86_64:desktop-4.0-amd64:desktop-4.0-noarch:graphics-2.0-amd64:graphics-2.0-noarch:graphics-3.2-amd64:graphics-3.2-noarch:graphics-4.0-amd64:graphics-4.0-noarch Distributor ID: SUSE LINUX Description: SUSE Linux Enterprise Server 11 (x86_64) Release: 11 Codename: n/a weblogic@F23-B4-E2-B1:~> cat /etc/SuSE-release SUSE Linux Enterprise Server 11 (x86_64) VERSION = 11 PATCHLEVEL = 1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值