43

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 
  • 6
    Please type file filename and report results. – January Sep 5 '12 at 9:46
  • filename is um.exe and result is bash: ./um cannot execute binary file – user87654 Sep 5 '12 at 9:52
  • 2
    That does not looks like a native Linux program. Try using wine. – Lekensteyn Sep 5 '12 at 9:54
  • this executable is compiled using a make file which compiles a set of fortran codes. this exe is made in fedora machine – user87654 Sep 5 '12 at 9:56
  • 1
    Please type file um.exe or file um (whichever is the name of your binary file). However, likely the generated binaries are for one reason or other Windows binaries. Also, if the program is public, you can post the link to the sources. Or just post the makefile here. – January Sep 5 '12 at 9:58
43

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.

| improve this answer | |
  • 3
    This is the most common reason I've seen for this problem, using file will identify this quite quickly. – mikebabcock Nov 15 '12 at 14:38
  • So there is no solution to this? – JohnMerlino Jul 4 '14 at 3:38
  • @JohnMerlino Either provide Hardware with the correct instruction set and a OS which enable it (AMD64 Hardware and OS for AMD64 Programs). or simulate/emulate/virtualize it (Virtual Box/JVM/...) or get a version for your instruction set. You can not run Software for other Instruction set as native Programs. – 12431234123412341234123 Aug 29 '17 at 13:11
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.

| improve this answer | |
4

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.

| improve this answer | |
4

For Googlers:

  • 32-bit or 64-bit? Check withfile yourbinary
  • Permission to execute? Do chmod +x yourbinary
  • Path correct? Do ./yourbinary
| improve this answer | |
1

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.

| improve this answer | |
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
| improve this answer | |
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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.