Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 708
Gorann Semara Avatar asked Jul 31 '10 06:07

Gorann Semara


People also ask

How do I find my OSX architecture?

To determine system type for macOSOpen the Apple menu and choose About This Mac. Click the System Report button. If you do not see a System Report button, click the More Info button and then click the System Report button. Under the Hardware panel, locate the Processor Name in the Hardware Overview.

How do I know if my Mac is static or dynamic?

If you are looking at a binary library / framework (perhaps it's precompiled by a 3rd party) and want to know if it's a static or dynamic binary, just use file command with the path to the binary file. Example (static framework) - static binaries are usually marked with ar archive or similar.

What is a macOS binary?

MacBinary is a file format that combines the two forks of a classic Mac OS file into a single file, along with HFS's extended metadata. The resulting file is suitable for transmission over FTP, the World Wide Web, and electronic mail.

What is lipo command in Mac?

lipo is a command tool which has been around in Mac OS X for a long time. It not only checks Mach-O files for their support of different architectures, but creates Universal Binaries too. In the past, a basic version of lipo has been provided in /usr/bin , and a more advanced version with Xcode.


2 Answers

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 
like image 56
Gary Avatar answered Oct 01 '22 12:10

Gary


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) 
like image 33
ubiyubix Avatar answered Oct 01 '22 13:10

ubiyubix