48

I couldn't execute a fortran compiled code in ubuntu 11.10 32 bit.

Error message is

bash: ./filename : Cannot execute binary file.

I've installed the gcc and gfortran libraries too.

Could anyone help?

$ file um
um: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped 
muru
  • 207,228
user87654
  • 481
  • 1
  • 4
  • 3

7 Answers7

46

As you can see from the output of file um that you posted in a comment, your binary is a 64-bit binary.

32 bit systems cannot run 64 bit binaries, it only works the other way around.

elmicha
  • 9,960
7

For Googlers:

  • 32-bit or 64-bit? Check withfile yourbinary
  • Permission to execute? Do chmod +x yourbinary
  • Path correct? Do ./yourbinary
dz902
  • 171
7

Another solution for people who are having this problem except the part about unmatched bits is that running the file without the command "bash".

Just use chmod +x 'path to the file' and then run 'the path to the file' in terminal.This is how I solved my problem.

Ravan
  • 9,567
Onurhan
  • 81
4

Try making the file executable

chmod +x um.exe

Then try running it

./um.exe

But if this is a exe file compiled for Windows, you probably need to install Wine.

carestad
  • 992
2

Another possible source of this error: trying to run a Linux binary executable on a Mac, or vice versa.

For instance, trying to run the true binary from my Mac on an Ubuntu box that I SCPed it to:

$ ./mactrue 
-bash: ./mactrue: cannot execute binary file: Exec format error

If you've downloaded a binary and executing it fails with this error, check if you've downloaded the version for the wrong OS.

0

For me, copying the binary into Applications on my Mac then into my Path messed it up on my Mac. I'm pretty sure the Applications folder turned the binary into an Alias instead of an actual binary.

-bash: /usr/local/bin/terraform: cannot execute binary file
mike$ file /usr/local/bin/terraform 
/usr/local/bin/terraform: MacOS Alias file

I unzipped the binary from my Downloads again and just mved it to my Path and it worked fine.

mike$ file /usr/local/bin/terraform
/usr/local/bin/terraform: Mach-O 64-bit executable x86_64
0

For me, I was working in a Vagrant (VirtualBox) VM but had unplugged the portable hard-drive on which the VM image was stored -- I plugged in the harddrive and rebooted the VM and my binary was executable again.

I guess a large part of the VM was loaded into memory as I could still use it and execute system binaries.