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

2
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 compiler for Windows it generates an executable that only works for Windows. What I want to know is what difference of the compilation process in the 2 operating systems?

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

    
asked by anonymous 17.04.2018 / 17:56

1 answer

2

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

Just like in a restaurant where you make the request informing you that you want the past, 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 say the same thing about the cook.

The Linux cook speaks ELF and windows speaks PE. So usually one does not understand the requests made to the other.

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

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

Here is a link to some executable format types (in Spanish, but I think which gives you an idea that has a lot)

    
20.04.2018 / 21:46