944,028 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 10563
  • C RSS
May 10th, 2007
0

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

Expand Post »
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..
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
therock4u is offline Offline
2 posts
since May 2007
May 10th, 2007
1

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

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.
Team Colleague
Reputation Points: 1135
Solved Threads: 172
Super Senior Demiposter
Rashakil Fol is offline Offline
2,479 posts
since Jun 2005
May 10th, 2007
0

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

That's because when you provide Chinese instructions to an OS that understands only French it won't understand.
Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007
May 10th, 2007
0

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

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?)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
therock4u is offline Offline
2 posts
since May 2007
Sep 16th, 2010
0
Re: Why linux executable(a.out) doesnt run on windows(.exe) directly?
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.
Last edited by -Powerslave-; Sep 16th, 2010 at 6:08 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
-Powerslave- is offline Offline
8 posts
since Sep 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Generate series
Next Thread in C Forum Timeline: searching a line from textfile in c





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC