On OS X, how do I find out what architecture a shared lib is compiled for?

孤者浪人 提交于 2019-12-30 01:46:07

问题


I need to know whether I compiled libjpeg for 32 or 64 bits architecture, but don't know how to find out, is there a command that will let me check?


回答1:


just type file libjpeg.dylib and you'll get output like the following

libpoll.dylib: Mach-O universal binary with 3 architectures
libpoll.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
libpoll.dylib (for architecture i386): Mach-O dynamically linked shared library i386
libpoll.dylib (for architecture ppc7400): Mach-O dynamically linked shared library ppc



回答2:


The file command will work just fine. Alternatively, you can use otool to print the fat headers.

$ otool -vf /usr/lib/libSystem.B.dylib
Fat headers
fat_magic FAT_MAGIC
nfat_arch 2
architecture ppc
    cputype CPU_TYPE_POWERPC
    cpusubtype CPU_SUBTYPE_POWERPC_ALL
    offset 4096
    size 2221800
    align 2^12 (4096)
architecture ppc64
    cputype CPU_TYPE_POWERPC64
    cpusubtype CPU_SUBTYPE_POWERPC64_ALL
    offset 2228224
    size 2169980
    align 2^12 (4096)



回答3:


Use the file command:

[mqudsi@iqudsi:Xcode/FSLogger]$ file ./original                   (07-31 02:53)
./original: Mach-O executable i386


来源:https://stackoverflow.com/questions/3377147/on-os-x-how-do-i-find-out-what-architecture-a-shared-lib-is-compiled-for

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!