What is the difference between a Windows and Linux compiler and executable

When compiling a simple program for Linux, the compiler generates an executable that only works on Linux, but when compiling the same code with a Windows compiler it generates an executable that only works for Windows. What I want to know is what difference from the build process in the 2 operating systems ?

If the code is the same, why is the end result different ? In which part of the compilation do the differences begin ? it is in the linkage part ? and why are there such differences ?

Author: silash35, 2018-04-17

1 answers

This answer is simplistic, but it tries to give an idea. Imagine that programs are a list of requests to do something.

As well as in a restaurant where you place the order stating that you want well passed, with or without onions, ..., this is just the request (your program). Who will actually prepare the dish (the operating system kernel) is in the kitchen tries to prepare according to your request (the program).

You will only eat what you want if you speak the same of cook.

The linux Cook speaks ELF and the windows one speaks Fr. So usually one does not understand the requests made to the other.

But there are some that are bilingual and can understand other formats. A very cool project is wine that runs Windows executables on linux (sometimes with better performance than on windows itself).

So it's just a matter of understanding the language to communicate with the operating system.

Here is a link for some executable format types (in Spanish, but I think you can get an idea that has a Lot)

 3
Author: Geraldo Luis da Silva Ribeiro, 2018-04-20 19:46:24