954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Why linux executable(a.out) doesnt run on windows(.exe) directly?

Dear all,

Why do i need to recompile the code?
Where as the X86 the architecture is same??
The final instruction are also going to be same right???
I assume there must be some difference between windows and linux executable handling in the sense of program loading (loader) but can some expert put some more highlight on this Please..

Thanks
Sirius..

therock4u
Newbie Poster
2 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

First, the program communicates with the operating system differently. To perform input and output, it must talk to the OS with a system call, using a particular protocol, and they use different protocols. Second, the libraries are different. Linux programs expect libraries with functions like printf and whatnot to be in particular places; Windows programs expect them somewhere else. Third, the filesystem and arrangement of where things are stored is different. Fourth, the executable file format is different. The Linux procedure which launches programs expects executable files to be in a particular format (or one of a set of formats?). The .exe file format(s?) is (are?) different. The general scheme of how GUI output is performed is different. The notion of processes is different. And on and on and on.

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
 

That's because when you provide Chinese instructions to an OS that understands only French it won't understand. :)

thekashyap
Practically a Posting Shark
811 posts since Feb 2007
Reputation Points: 254
Solved Threads: 75
 
First, the program communicates with the operating system differently. To perform input and output, it must talk to the OS with a system call, using a particular protocol, and they use different protocols. Second, the libraries are different. Linux programs expect libraries with functions like printf and whatnot to be in particular places; Windows programs expect them somewhere else. Third, the filesystem and arrangement of where things are stored is different. Fourth, the executable file format is different. The Linux procedure which launches programs expects executable files to be in a particular format (or one of a set of formats?). The .exe file format(s?) is (are?) different. The general scheme of how GUI output is performed is different. The notion of processes is different. And on and on and on.

Thank you very much for your information..
just for a little bit of clarity... does it mean that loader which loads the program is actually OS specific (as it deals with actual allocation of memory and pysical address mapping for program and providing program counter to processor ) and
linker OS-independant.. if not what OS - Dependant information linker provides in ELF ( executable of linux?)

therock4u
Newbie Poster
2 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

Hi! Yes, it is a bit late, but however...
Executables are usually not pure codes, but various mixture of pure code, metadata that are OS specific, external function calls that are usually OS specific, and mostly, OS specific system calls too for input/output. System level activities like direct disk access are disabled by the OSes, and programs must call the systems' own functions with specific parameters to make action.

For example an executable could contain a call like
func_anOS_hddoper_openfile(discnum,pathstr,fname,mode_byte);

for a certain OS while the other OS' function expects f_otherOS_openFileFromDisk(diskIdentifierString,fullPath,fileModeWord);

for the same purpose that's incompatible with he former one.
Variables can be different types, input/output data can be handed in different format, and different manner, therefore one cannot interpret commands/data for the other. It's a metter of how the execution environment is implemented.

-Powerslave-
Newbie Poster
8 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You