Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what are the differences between an executable generated by windows and linux [duplicate]

Possible Duplicate:
Why an executable program for a specific CPU does not work on Linux and Windows?

Why can't programs written in linux be executd in windows ? Suppose I compile a simple C program containing function calls that are common to both windows and linux, Does the compiler generate different binary under windows and linux ?

like image 555
Sharat Chandra Avatar asked Dec 03 '22 06:12

Sharat Chandra


2 Answers

They use different container formats.

Most Linux executables are ELF files; all Windows executables and DLLs are PE files.

like image 171
SLaks Avatar answered Dec 04 '22 20:12

SLaks


Here are some of the reasons I can think of off the top of my head:

  1. Different container formats (which so far seems to be the leading differentiator in this answer -- however its not the only reason).
  2. different dynamic linker semantics.
  3. different ABI.
  4. different exception handling mechanisms -- windows has SEH -- upon which C++ exception handling is built
  5. different system call semantics and different system calls -- hence different low-level libraries.
like image 44
Hassan Syed Avatar answered Dec 04 '22 21:12

Hassan Syed