28

Is it possible to get information about any binary on OS X to determine if it's a 32 bit or 64 bit binary?

I played with the 'otool' command but can't find this kind of information.

nalply
  • 26,770
  • 15
  • 78
  • 101
jideel
  • 482
  • 2
  • 8
  • 14

2 Answers2

43

Use the file command instead of otool. It will list all the architectures in the binary. On Intel Macs i386 is 32 bit and x86_64 is 64 bit.

Grant Lammi
  • 1,324
  • 11
  • 5
  • Great ! shame on me for not finding this :) – jideel Dec 21 '09 at 21:54
  • 9
    `lipo -info` is more useful for determining the architecture on static libraries. – greg Dec 05 '11 at 16:33
  • `file /path/to/your/binaryFile` on macOS 10.14 Mojave worked great for me on a large variety of executables, be it the executable within a .app bundle or printer drivers, plugins, etc. – porg Aug 22 '19 at 10:03
11

From Nicholas in a comment, lipo -info also works. This is what you must use on static libraries, since file only displays "current ar archive random library."

greg
  • 4,843
  • 32
  • 47
  • The only problem with `lipo -info` is that it errs on non-binary executable files. For example, if you're running GNU `find` like this: `gfind /opt/local/bin -executable -exec lipo -info "{}" \;`, you'll get errors on scripts. E.g. `fatal error: lipo: can't figure out the architecture type of: /opt/local/bin/hg` In such cases, `file` is a better command to use. – GDP2 May 21 '18 at 02:26