How to solve: -bash: : cannot execute binary file
I have a file named b1 that contains assembly language. I am trying to execute the file on OSX using
$ ./b1
I get the following error:
-bash: ./b1: cannot execute binary file
I've looked at other similar questions, but to no avail. I'm definitely using a 64 bit architecture.
Here are output of relevant info:
$ file b1
b1: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
$ uname -a
Darwin Anthonys-MacBook-Pro.local 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64
Edit:
Ran as b1
which ended up terminating with:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/as: fatal error in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../libexec/as/x86_64/as
Sorry, this file is for GNU/Linux
According to your file
output, this program is for GNU/Linux. I know this because:
- The file
b1
is in theELF
(Extensible and Linkable Format) format, while Mac OS X uses theMach-O
format for binaries; -
file
recognizes this file is forGNU/Linux 2.6.18
, meaning it'll work on most modern Linux distributions.
To solve your problem, you must either run this problem within a Linux distribution, recompile the program, or get the Mac OS X version of this program.
So... Why doesn't b1
work on XYZ OS or CPU?
Just as people speak different languages, different computers understand different instructions. For instance, your Mac uses an Intel processor, while your Android phone uses an ARM processor. Compare these two processors to English and French. They may belong to the same language family, but still, you can't speak both at the same time. This leads to a conclusion:
Dissimilar computers "talk" in different tongues.
As for why different operating systems (such as Windows, Mac OS X, and Linux) can't use the same binaries, consider this:
What makes software objectively different to hardware? Not much.
Both provide a system and a "language" that allows for more complex components of the computer to complete tasks for the end user. Both require an agreed language to get work done. Imagine if there were 10 people in a shouting match, each speaking a different language. This is why different OS software need different binaries, even if both operating systems use the same processor.
assembly language? You need to compile it, or rather assemble it.
man as