Why won’t Windows EXE files work on Linux?

What is different about the way Windows runs an executable and Linux runs an executable? Why did they have to be different? Besides, why don’t Linux executables have a file extension?


I’m not asking about how to make a EXE file work on Linux.

I’m asking why it does not work.

Solution:

Linux and Windows executables use different formats. Linux uses the ELF format on most architectures, while Windows uses the PE format. ELF is better suited to the way Linux manages shared libraries, and PE is better suited to the way Windows manages shared libraries, but there’s no fundamental reason why Linux couldn’t execute PE executables or Windows ELF executables. In fact Linux can execute PE executables, through Wine.

The difficulty is that Windows and Linux have completely different APIs: they have different kernel interfaces and sets of libraries. So to actually run a Windows application, Linux would need to emulate all the API calls that the application makes. That’s a lot of work. Wine does it to some extent, but it’s very hard, especially since the maker of Windows doesn’t cooperate. You can compare it with, say, learning English when your native language is Chinese: the executable format is the alphabet (not that hard to master), the API is the vocabulary (takes years to get to a level where you can start reading literature).