I'm trying to run a program, but it gives an error:
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?
I'm using Ubuntu 14.04.2 (amd64) with VMware. I also tried using Ubuntu i386, but the result was the same.
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:
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);
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
,qemu
, andqemu-user-static
packages: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.Such error may occur if all of the following are true:
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/
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 thejava
I needed.I choose 2 and set
openjdk-8
as a default. Which did not show theExec 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:
This can also happen if the binary uses a libc implementation which is not libc, such as musl. These days this specific problem is most likely encountered when trying to run a binary with libc in a Docker container with an image based on alpine. There is nothing that can be done to the binary itself to support both environments, because the libc implementation must always be linked statically, i.e. built directly into the binary, for reasons.
I got this error trying to run a zip file containing an executable rather than extracting it and running the executable itself xD
In addition to the other answers offered here, I suppose there would be a lot of file types that aren't intended to be executable which could cause this error.
This is another special case: WSL (Windows Subsystem for Linux) by default(!) only supports 64bit executables. I think this is a rather unusual behaviour, as normally there is a backwards compatibility.
(Even more special is that selecting 64bit in a formerly 32bit project of Windev won't fix your issue. You need to start a new project, selecting 64bit right in the beginning. Tested on Windev 26. This IDE sucks, forced to use it because of working legacy code.)