I'm trying to run a program, but an error happens like this:

bash: ./program: cannot execute binary file: Exec format error

The result of file program was:

program: ELF-32-bit LSB executable, ARM, EABI4 version 1 (SYSV), dynamically linked(uses share libs), for GNU/LINUX 2.6.16, not stripped

How can I fix this error?

I'm using Ubuntu 14.04.2 (amd64) with VMware. I also tried with Ubuntu i386, but result was same.

  • 4
    It's an ARM executable, i.e. you downloaded the wrong executable format or compiled for the wrong platform. You have to get the right executable or recompile. – Karl Richter Jul 15 '15 at 9:24

You're trying to run an executable compiled for an ARM architecture on an x86-64 architecture, which is much like asking your processor who only speaks English to take directions in Chinese.

If you need to run that executable you have two choices:

  1. Get an x86-64 version of the executable (by any mean; if you're unable to get an x86-64 version of the executable but you're able to get its source code, you can try to recompile it on the virtual machine);

  2. Install Ubuntu Server for ARM in place of Ubuntu 14.04.2 (amd64). This requires either a physical machine running on an ARM architecture or a virtualization software that can emulate it.

This can also occur if you attempt to run an x86-64 executable on a 32-bit platform.

In one specific instance, I downloaded Visual Studio Code and tried to run it on my Ubuntu installation, but I hadn't realized that I had installed 32-bit Ubuntu in this VM. I got this error, but after downloading the 32-bit version, it ran without issue.

It is often possible to run an ARM executable image on an amd64 system if you install the binfmt-support Install binfmt-support, qemu Install qemu, and qemu-user-static Install qemu-user-static packages:

sudo apt install binfmt-support qemu qemu-user-static

qemu will then perform syscall emulation when you run the executable. This works for most ARM binaries but there are a few that may not run correctly.

  • sudo apt-get install binfmt-support qemu qemu-user-static – Momin Al Aziz Jul 5 '17 at 18:38

Such error may occur if all of the following are true:

  • Executable is not a file but a link
  • You run run it inside VM
  • File is located in shared folder
  • Your host is Windows.

If you got that file, let's say, in archive - try to unpack it inside VM, in some directory inside virtual drive, not folder mapped to your host machine hard drive, for example /myNewDir/

  • That's pretty helpful. For me, I created a shortcut (link) to that executable file, then executing the shortcut gave me the error. – Duc Tran Mar 30 at 20:57

If more than one java is installed on the system this might happen and not set as default. On Ubuntu14.04 LTS I could get it resolved by executing following and choosing the java I needed.

sudo update-alternatives --config java
[sudo] password for user: 
update-alternatives: warning: /etc/alternatives/java has been changed (manually or by a script); switching to manual updates only
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      auto mode
  1            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1069      manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in manual mode

I choose 2 and set openjdk-8 as a default. Which did not show the Exec format error.

You must compile your file using an appropriate CPU architecture (x86 for example) and copy the .exe file on your linux machine. Then you can install mono on your linux machine and issue the following command:

mono myprogram.exe

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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