35

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.

1

3 Answers 3

54

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).

16
  • 11
    "Vocabulary" is an excellent analogy. Nov 11, 2010 at 18:32
  • I think you meant completely different. Nov 11, 2010 at 21:28
  • Android also supports Linux bnaries(not packages) if they are compiled for ARM because it is based on Linux
    – Suici Doga
    Feb 20, 2016 at 8:11
  • @SuiciDoga Sort of, but it's more complicated than that. The Android kernel can run Linux binaries (if they're compiled for the right kernel ABI, e.g. wrt the use of NEON registers), but if you want to run dynamically-linked programs, you have to install all the libraries as well. (And if you do that you could install a package manager too, so “binaries but not package” isn't really true.) Feb 20, 2016 at 14:01
  • Yes ,I know about that you have to change library path etc
    – Suici Doga
    Feb 20, 2016 at 15:32
14

Windows binaries have a different ABI and use a different API than Linux binaries.

Linux binaries don't need an extension because *nix uses permission bits to identify an executable instead of the extension.

6
  • 1
    Agree with the answer...additional piece of data that may be relevant: ELF(en.wikipedia.org/wiki/Executable_and_Linkable_Format) vs PE(en.wikipedia.org/wiki/PE_executable) Nov 11, 2010 at 13:33
  • Ah yes, it needs a different loader as well. en.wikipedia.org/wiki/Loader_%28computing%29 Nov 11, 2010 at 13:35
  • I especially like the second piece of information missing from the answer by @Gilles.
    – Timothy Gu
    Dec 7, 2014 at 6:01
  • @IgnacioVazquez-Abrams That's very interesting. What if i told you that i just run a windows game PlantsVsZombies.exe on Ubuntu 16.04 Linux natively? I just did that out of boredom knowing that it would not launch, but it did and i could play it perfectly fine. That's like impossible, because that game needs the steam api to run first and it clearly didn't. How did it launch??? Should i make a new question for that?
    – KeyC0de
    Feb 24, 2017 at 19:56
  • @RestlessC0bra: Wine and Mono are things. Feb 24, 2017 at 21:15
0

This is how I heard the Windows side explained in layman's terms from programmers.

In Windows there are hooks in programs and the OS that EXE files make calls to that just won't be there in Linux. Because of the differences in both the environments. Initially Linux looks for permissions, and Windows looks for a linkable format first by examining the extension, looking at properties, and then looking inside the EXE file, etc.

There are applications like Netbackup that started out on Linux and have been modified to run in a Windows environment without using Wine. IMHO, frequently those are some of the most stable best behaving Windows applications.

When Windows applications become unruly usually it is because some of those hooks held by the application weren't completely released and Windows thinks they were (memory leaks). When Windows hands that unreleased memory space out to another application, it crashes and burns.

2
  • 2
    Somehow I'd like to believe that Bill Gates answered my question ;-)
    – Nav
    Jul 31, 2016 at 17:24
  • Re "When Windows hands that unreleased memory space out to another application, it crashes and burns.": That doesn't sound plausible, even in 2010. Dec 18, 2020 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.