Why does a program compiled for Linux not run on Windows?

Asked

Viewed 189 times

2

Well, we know that Linux and Windows run on x86 architecture but why a program made for Linux does not run on Windows?

Since Windows is multi-architecture, a program made for Windows that runs on x86 can run on another processor architecture?

  • Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site.

1 answer

3

Why executables are different between operating systems

Linux and Windows run on several processor architectures, not just x86. Linux in a larger amount. The architecture that runs most nowadays on normal computers is the x64, and the ARM probably even more if it enters in all types of devices.

Each operating system has its own API and ABI, then the format of the executable, way to communicate with the rest and even what has available to call in the operating system is different, so each executable is built in a completely different way, although the instructions executing the main code may be the same.

Simply put, each OS has its basic library of services that they provide to applications and the executable has to deal with the OS library for which it was created.

Note that it is possible to generate an executable in one OS but that works in the other system. Obviously it will not run where it was generated, only in the OS for which it was aimed.

Why executables are different between architectures

Also worth it for the same operating system can not run on different architectures. The processor instructions of each is different, then the executable has to have the instructions that that processor understands. The executable made for one processor does not run on another.

There are tricks that some executables do that can compatibilize executables to some extent. It needs at least one specific part for each architecture (processor) or platform (operating system), but the application itself can be generic. This occurs with applications that will be interpreted directly, or that will run through a virtual machine with a bytecode own, or will generate a code native to that platform/architecture at the time of execution through a Jitter.

  • Let me get this straight so the instructions are not dedicated to the processors but to the operating systems?

  • 1

    No, read the answer again, you’re mixing information from one paragraph to another, and that’s what comes of asking two questions together, you get two answers together.

  • All right thank you

  • "Simply put, each OS has its basic library of services that they provide to the applications (its API) and the executable has to deal with the OS library for which it was created." That’s the gist, the essence, of the issue.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.