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