LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Do Linux Binary Files work across all platforms/CPU types? (i.e. Between PC/Mac) (https://www.linuxquestions.org/questions/linux-newbie-8/do-linux-binary-files-work-across-all-platforms-cpu-types-i-e-between-pc-mac-573777/)

bookerg 07-31-2007 05:25 PM

Do Linux Binary Files work across all platforms/CPU types? (i.e. Between PC/Mac)
 
Hi all (Linux Newbie here).


This question may seem glaringly obvious to some of you, but I'm completely stuck. I know (from what I'm told) that generally speaking, binary/executable files are said to only work on the type of processor that they were originally compiled for (whether it be x86, PowerPC, etc.)


However, does the same story apply if an Operating System (such as Linux) acts as an "intermediate"?


What I mean is - if I download a binary/executable "Linux" file, will it work just the same on an x86 PC running ubuntu Linux as it would on an Apple Mac running ubuntu Linux? Or does it have to be compiled separately for each processor type by having access to the source code?



(P.S. There's no particular reason why I used ubuntu Linux as an example above, rather than any other Linux distro)



Many thanks to all who can help out :)

stress_junkie 07-31-2007 05:40 PM

Binary executables only work on one specific CPU type.

There are some applications that emulate specific processors. If you were running an x86 machine but had an emulator that emulated a G4 processor then you could execute G4 binaries within that G4 emulator running on the x86 machine.

When we talk about different CPU types we have to keep in mind that we are also talking about the supporting hardware designed for that CPU type. For example an x86 processor doesn't access RAM in the same way that a G4/Power PC chip accesses RAM. So a binary compiled for a particular CPU type also has instructions for reading disks and writing to the monitor that are unique to that CPU family. The CPU emulators take care of that supporting hardware emulation as well as the specific CPU instructions.

bookerg 07-31-2007 05:48 PM

Quote:

Originally Posted by stress_junkie
Binary executables only work on one specific CPU type.

There are some applications that emulate specific processors. If you were running an x86 machine but had an emulator that emulated a G4 processor then you could execute G4 binaries within that G4 emulator running on the x86 machine.

Hi.

So if I download a binary Linux file (specifically in this case, a console emulator from Zophar's Domain), it's safe to assume that it has been compiled for an x86 processor? (unless stated otherwise, I don't think it would be compiled for an Apple Mac or anything)


With that in mind, how difficult is it to compile the source code to get it to work with a different processor? Does it entail any actual coding, or will the compiler automatically just "get it work" ?


All times are GMT -5. The time now is 09:01 AM.