The message – cannot execute binary file:exec format error – occurs when you try to execute the file that is not in the right executable format. This error happens due to numerous reasons, such as the file contains a different architecture or has an object code file but not an executable file. The error is common on the Linux operating systems or on Ubuntu 18.04 x 86-64 target. It can occur on Windows operating systems too. Here are some effective ways to fix cannot execute binary file:exec format error for your assistance:
Check the File Architecture
Step 1: Ensure you have the right binary file. Usually, Binary files made for 32-bit systems do not work on 64-bit systems. And similarly the files made for 64-bit systems do not work on 32-bit systems.
Step 2: Open the Command Prompt.
Step 3: Type the command – file filename – in the window.
Step 4: Try running the respective binary file if the file architecture does not match between the file and the computer.
Examine the File
Step 1: Keep in mind the Binary files made for one operating system cannot run on a device with another operating system.
Step 2: Check whether a Binary file is made for Windows or Linux.
Step 3: Run the file on Windows if it is made for Windows operating systems or run on Linux if it is made for Linux operating systems
Step 4: Use Wine to run the Binary files made for Windows on Linux.
Install Gfortran and GCC
Step 1: Use Gfortran and GCC to execute Binary files well.
Step 2: Use the command – sudo apt-get install gfortran && sudo apt-get install build-essential – to install them.
Uncompress the Binary File
Step 1: Check whether the Binary files are compressed.
Step 2: Uncompress the files if they are compressed.
Step 3: Type in the following commands to uncompress a Binary file.
xz -d ./filename
chmod +x ./filename
./filename
Inquire about the File Permissions
Step 1: Check whether the binary file has permissions to read or change.
Step 2: Change the file permission settings if the file has no read or change permissions for a user. For it, run the command – chmod +x filename.
Utilize Dos2unix
Use the command – dos2unix filename.bin. It will enable the file made for DOS run on UNIX systems.