Is a Linux executable “compatible” with OS X?

前端 未结 5 1151
孤城傲影
孤城傲影 2020-11-29 08:08

If you compile a program in say, C, on a Linux based platform, then port it to use the MacOS libraries, will it work?

Is the core machine-code that comes from a comp

5条回答
  •  萌比男神i
    2020-11-29 08:47

    "bytecode" usually refers to code executed by a virtual machine (e.g. for java or python). C is compiled to machine code, which the CPU can execute directly. Machine language is hardware-specific so it it would be the same under any OS running on an intel chip (even under Windows), but the details of how the machine code is wrapped into an executable file, and how it is integrated with system calls and dynamically linked libraries are different from system to system.

    So no, you can't take compiled code and use it in a different OS. (However, there are "cross-compilers" that run on one OS but generate code that will run on another OS).

提交回复
热议问题