无法在 mac 上运行二进制文件,在 Linux 上运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8233518/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
unable to run a binary in mac,running on Linux
提问by code4fun
I am using a software for graph mining. I have got the binary of that software in 2 folders for Linux mode and SunOs mode but don't have the source. I am able to run the binary in Linux machine. But when I want to run the binary in a Mac machine I am getting "command not found" for both the Linux and SunOs folders' binaries.
我正在使用图形挖掘软件。我在 Linux 模式和 SunOs 模式的 2 个文件夹中获得了该软件的二进制文件,但没有源代码。我能够在 Linux 机器上运行二进制文件。但是当我想在 Mac 机器上运行二进制文件时,我收到了 Linux 和 SunOs 文件夹二进制文件的“找不到命令”。
Could someone suggest if it can be able to run this in a MAC machine by any means like using a Linux shell or something
有人可以建议它是否可以通过任何方式在 MAC 机器上运行它,比如使用 Linux shell 或其他东西
Gaurav
高拉夫
EDIT:I am getting "cannot execute binary" error when I set chmod to "u+x"
编辑:当我将 chmod 设置为“u+x”时出现“无法执行二进制”错误
回答by Dave Newton
You'll need to recompile it for OS X or use a VM.
您需要为 OS X 重新编译它或使用 VM。
A command not found just means you're not executing it right, make sure it's chmod u+x
and it's either on your PATH
, or you specify the path explicitly.
未找到命令仅意味着您没有正确执行它,请确保它chmod u+x
在您的 上PATH
,或者您明确指定了路径。
回答by Diego Torres Milano
If you use the file command you will see the difference, on the linux executable you'll have something like:
如果您使用 file 命令,您将看到不同之处,在 linux 可执行文件上,您将拥有如下内容:
ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.15, not stripped
ELF 64 位 LSB 可执行文件,x86-64,版本 1 (GNU/Linux),静态链接,用于 GNU/Linux 2.6.15,未剥离
and something like this for OS X executables:
对于 OS X 可执行文件,类似这样的事情:
command: Mach-O universal binary with 2 architectures command (for architecture x86_64): Mach-O 64-bit executable x86_64 command (for architecture i386): Mach-O executable i386
命令:具有 2 个架构的 Mach-O 通用二进制命令(适用于架构 x86_64):Mach-O 64 位可执行 x86_64 命令(适用于架构 i386):Mach-O 可执行文件 i386
回答by Grady Player
Operating systems generally don't support executing object code any extra formats... If Mac osx decended from solaris or Linux, then there could be some incentive for legacy support. But just assume everything to be binarily incomparable if it was compiled for a different arch and platform. There are a few places where you inherit backwards compatibility, running 32 but code on 64 bit oses... Or ppc code support on intel macs, but I suspect that both of those, especially the latter were non trivial engineering tasks.
操作系统通常不支持执行任何额外格式的目标代码......如果 Mac osx 从solaris 或Linux 下降,那么可能会有一些对遗留支持的激励。但是,如果它是为不同的架构和平台编译的,那么假设一切都是二进制不可比较的。有几个地方继承了向后兼容性,在 64 位 oses 上运行 32 但代码......或者在 intel macs 上支持 ppc 代码,但我怀疑这两个,尤其是后者都是非平凡的工程任务。
Here are your options... Get the source and compile on the Mac, if it compiles on Linux and solaris good chance it will compile and run ok on Mac.
这是您的选择... 获取源代码并在 Mac 上编译,如果它在 Linux 和 solaris 上编译,它很有可能在 Mac 上编译和运行。
Run through an emulator or boot camp
运行模拟器或新兵训练营