/bin/bash: cannot execute binary file

28 views (last 30 days)
Simon Lind
Simon Lind on 13 Aug 2016
Commented: Walter Roberson on 17 Aug 2016
Greetings,
I think a similar question has been asked before, but I couldn't find the answer I need.
I'm trying to run a .exe file from matlab as
system('./file.exe')
But I got this error
/bin/bash: ./file.exe: cannot execute binary file
I hope someone could help, I'd really appreciate it.
thanks
ps:
file /bin/bash /bin/bash: Mach-O 64-bit executable x86_64
  1 Comment
Geoff Hayes
Geoff Hayes on 14 Aug 2016
Carl - what can you tell us about the executable? What does it do? Have you tried including the full path to this executable? What happens when you try to run this from the command line (through a terminal window outside of MATLAB)?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 14 Aug 2016
Mach-O 64-bit executable x86_64 are used by OS-X, iOS, and some other operating systems derived from the MACH kernel. The only one of those that runs MATLAB these days is OS-X. However, OS-X does not use the .exe file extension, which hints you might be trying to execute the file on the wrong machine.
However, it is true that on Unix derivatives, the file extension is not the important feature for determining whether a file can be executed from the command shell by direct reference the way you show using ./file.exe . Instead what is required first is that the file have its execute permissions set as far as the user is concerned. If the execute bits are not set then you would receive a "Permission denied" message.
With the execute bits set, the operating system would look at the "magic number" to try to determine how the file should be executed. For text files, the "magic number" is "#!" as the first two characters of the file. For Mach-O 64 bit binaries that do not show up as "fat" binaries, the magic number involves in part the file starting with hex FE ED or hex CF FA. "file" indicates that those bytes are properly present in the file. If you were using OS-X and those bytes were not present then you would get an error message about trying to execute a binary file; likewise if you were using some other operating system and trying to execute mach-o files then you would get the same message. For example you would have a problem if you tried to execute such a file under Linux.
At this point we are stuck because we do not know which operating system you are running.
  4 Comments
Simon Lind
Simon Lind on 17 Aug 2016
Edited: Simon Lind on 17 Aug 2016
Thanks
Yes I got those files from a previous installation I did (DATA folder etc), perhaps I should try re installing on my new El Capitan machine.
Anyway, running the exe directly from a terminal gives the same answer (cannot execute binary file)
Thank you
Walter Roberson
Walter Roberson on 17 Aug 2016
I would suggest recompiling, yes.
You might also be having difficulties with a library not being on the DYLD_LIBRARY_PATH at the time you execute, but the message would typically be different than that.

Sign in to comment.

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!