cygwin binary exec format error

15,300

Solution 1

  1. Your file is not an executable. It most probably contains ELF executable which is designed for Linux operating system, or it's corrupt.
  2. If your file was a shell script, or in fact anything that contained plain text, you'd get different errors (such as, "expected command name" or "unknown command: XYZ" etc.)
  3. Scripts are not supposed to have file extensions, like any executables. On the other hand, they should have shebangs: small text located in the first line that tells the system the path to the interpreter. For example, a Python executable script might be named whatever and have #!/usr/bin/python3 or similar in the first line. When you run it through ./whatever in the shell, it'll look for python3 in /usr/bin and run your file like this: /usr/bin/python3 ./whatever. (In fact, thanks to this you can also specify additional parameters that get passed to the interpreter.)

There is also a chance that your script is valid, but it contains a shebang pointing to bad interpreter. If that is the case, then most likely the path is correct, otherwise you'd get /whatever/interpreter: bad interpreter: no such file or directory error or similar. But then, all the other points apply to the interpreter (which is just another executable...)

If the script and/or interpreter was meant to be executed on Windows or Cygwin at least, it should either contain aforementioned shebang (#!/path in the first name) or it should be Windows executable (in which case the file data should begin with MZ letters, you can inspect it in notepad.) If it isn't, it means the files you were given can't run on Cygwin.

Solution 2

In my case, I got the error when I used a wrong command to compile my C program. When I used the right command:

gcc myprog.c -o myprog.exe

the error was resolved.

Solution 3

Had this same problem. Added the following at the top of makefile:

export ARCH = CYGNUS

What happened during the make process is that Linux and Windows versions of the executables were created. You just have to use ./.exe versions.

Share:
15,300
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    I have a script file that I was given to run in windows using Cygwin. When I try to use this file I get the following error

    -bash: /sigdet/filename: cannot execute binary file: Exec format error.

    sigdet is the folder within the Cygwin directory that I have the script. Rawdata is the name of the directory with the raw data files that the script is supposed to analyze.

    To try and solve this, I have changed the file permissions, I have checked to make sure that it is on a 64 bit machine and the script appears to have compiled on a 64-bit machine. After these steps, I don't know what else the problem could be. Here are the commands I've entered:

    I first changed the directory like so:

    $ cd /sigdet/

    Then I ran the script that is suppsed to work:

    $ /sigdet/filename -i rawdata

    Does the script file need to have an extension in windows? I've tried changing it to a .sh extension with no luck. I'm told that it just works on other windows machines just how it is.

    Thanks to anyone that can help with this.