/bin/bash: cannot execute binary file

13 次查看(过去 30 天)
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 个评论
Geoff Hayes
Geoff Hayes 2016-8-14
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)?

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2016-8-14
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 个评论
Simon Lind
Simon Lind 2016-8-17
编辑:Simon Lind 2016-8-17
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 2016-8-17
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by