Getting the error: bash: (program): cannot execute binary file: Exec format error, on both 32-bit and 64-bit Windows
Asked Answered
H

3

13

There is a program developed for linguistic research (http://people.csail.mit.edu/mcollins/code.html). When I try to run the parser using Git bash terminal on Windows, I get the error:

bash: cannot execute binary file: Exec format error.

First, I assumed it's because of my 64-bit OS, since the file is 32-bit. So, I tried the program on a 32-bit system, but got the same message.

Any ideas on how to fix the issue?:

file (program) shows:

ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.2.5, with debug_info, not stripped

uname -srv for my 64-bit OS, shows:

MINGW64_NT-10.0-19042 3.1.7-340.x86_64 2021-03-26 22:17 UTC

uname -srv for my 32-bit OS, shows:

MINGW32_NT-6.1-7601 3.1.7-340.i686 2021-03-26 22:01 UTC

P.S.: If you'd like to give it a try, this code should work in the program directory, but it doesn't work for me:

gunzip -c models/model2/events.gz | code/parser examples/sec23.tagged models/model2/grammar 10000 1 1 1 1 > examples/sec23.model2
Hawaii answered 6/4, 2021 at 14:45 Comment(5)
Edit your Q to show the output of uname -srv . Good luck.Caravansary
What terminal emulator are you runing ? WSL (1 or 2 ?) ? CygWin ? Something else ?Bitolj
I'm using Git bash. @BitoljHawaii
Tried it with CygWin, and got the same result.Hawaii
@Hawaii cygwin isn't a Linux environment either. Cygwin binaries are native Windows binariesCristie
C
11

As indicated by file, your program is a Linux application so you can't run it on Windows. See

Mingw is not an environment for running Linux executables, it's just a compiler that compiles POSIX code into native Windows binaries. Neither is Cygwin, which is a reimplementation of POSIX system calls in Windows, and Cygwin binaries are also native Windows binaries with a dependency on Cygwin DLLs. Read this if you want to know their differences. Bash is a shell and isn't a platform to execute files either. Only the runtime platform (OS or something like JVM or .NET CLR VM) can run programs and a shell is just a tool to interact with the OS

So you must run Linux programs in a Linux environment like a Linux machine or WSL1/2. Since the program is 32-bit, you can only run it in Linux or WSL2

Since you have the source code you can also compile the code with mingw or cygwin and run on Windows

Cristie answered 6/4, 2021 at 15:7 Comment(0)
J
4

I have ran into same issue on Ubuntu Server and got the following error:

-bash: /usr/bin/my-script: cannot execute binary file: Exec format error

I found a general solution for running x86-64 files on arm CPU. Running the following code fixed it:

sudo apt update
sudo apt install -y qemu-user-static binfmt-support
sudo dpkg --add-architecture amd64
sudo apt update
sudo apt install libc6:amd64

Source : https://www.kali.org/docs/arm/x86-on-arm/

Jokester answered 24/8, 2023 at 22:18 Comment(3)
the question was tagged windows so this doesn't answer itCristie
Yeah I know but after searching so long here was only SO page I found so I tough it might be a good idea to help others who came here from Linux environment.Jokester
if there's no question like this for Linux then you can simply ask one and post a self-answerCristie
H
2

Thanks to the answer provided by @phuclv, I realized I need to run the program in Linux. So, I installed 32-bit Linux (I used Linux Mint Debian Edition) on a virtual machine (VirtualBox) on my 64-bit Windows 10, and it worked!

Hawaii answered 7/4, 2021 at 7:22 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.