daniels
daniels

Reputation: 19193

How can I check if a compiled binary is 32-bit or 64-bit?

I have a Mac running Lion and I just downloaded latest version of apache. I did the usual things:

$./configure --prefix=/Users/daniels/Sandbox
$ make
$ make install

For what architecture is the httpd binary compiled? x86 or x64? Is there a way to find this?

What I am looking for is that I want to make a MAMP-like application and I want to compile Apache, PHP, and MySQL in such way that I can put them in a DMG file and then give it to other people and they can run it.

Upvotes: 15

Views: 10711

Answers (3)

Alex Zavatone
Alex Zavatone

Reputation: 4323

The lipo binary also does this.

lipo -archs

$ lipo -archs 'Adobe Photoshop Lightroom 5'
x86_64 

lipo -info

$ lipo -info 'Adobe Photoshop Lightroom 5'
Non-fat file: Adobe Photoshop Lightroom 5 is architecture: x86_64

Upvotes: 3

kenorb
kenorb

Reputation: 166309

An easy way to determine if the Apache is 32-bit or 64-bit is to execute the following in the global zone by using dtrace:

sudo dtrace -qn 'syscall::: /execname == "httpd"/ { ab = (curpsinfo->pr_dmodel == PR_MODEL_ILP32) ? "32-bit" : "64-bit" ; exit(0); } END { printf("Apache: %s",ab); }'

Upvotes: 1

Royce
Royce

Reputation: 552

Check out the file command.

$ file /usr/bin/grep
/usr/bin/grep: Mach-O universal binary with 2 architectures
/usr/bin/grep (for architecture x86_64):    Mach-O 64-bit executable x86_64
/usr/bin/grep (for architecture i386):  Mach-O executable i386

Upvotes: 24

Related Questions