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..

Recommended Answers

All 4 Replies

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.

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

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.