Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

macos

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.

like image 794
daniels Avatar asked Sep 19 '11 13:09

daniels


People also ask

How do you check if a binary is 32 or 64-bit?

Open the Task Manager by simultaneously pressing the Ctrl + Shift + Esc keys on your keyboard. Then, click on the Processes tab. In the Processes tab, you see the list of processes that are running at the moment. If a program is 32-bit, near its name you should see the text: *32.

How do I know if a DLL is x86 or x64?

Launch depends.exe, go to File, click Open... and open the desired DLL file. In the Module section find the Module with the name of the DLL that you opened. The CPU column tells if the file was compiled for 32 bits or 64 bits.

How do I know if I have a 32-bit or 63 bit?

Look for the System Type option under the Item column on the right side of System Information. In the Value column, the associated value tells you which type of CPU the computer has in it. If the System Type value includes "x86" in it, the CPU is 32-bit. If the System Type value includes "x64" in it, the CPU is 64-bit.


3 Answers

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
like image 124
Royce Avatar answered Nov 01 '22 16:11

Royce


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
like image 23
Alex Zavatone Avatar answered Nov 01 '22 18:11

Alex Zavatone


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); }'
like image 1
kenorb Avatar answered Nov 01 '22 16:11

kenorb