Quote:
Originally Posted by nalg0rath Short answer: No, it wont run on any system. |
True. The architecture is determinant and so it is the compatibility at ABI level. For example, if you compile anything against glibc-2.4, more tan probably, it will not run on a system with glibc-2.8. Some times, as you very well said, this can be overcome to a certain extent by compiling the libs statically on the same binary file. This eliminates the need to link against external libraries.
Quote:
|
You cannot run binaries for different processortypes if your processor type does not have backwards compability so that it supports the instructions of the architecture the binary was compiled for. In practice it does not even work when you have backwards compability unless the programmer is very careful to make the program portable. You wont be able to run a amd64-, sparc64-compiled binary on a i386 machine.
|
Yep. This is why linux distributions offer many binary copies of the same package, one for x86_64, one for x86, one for sparc, arm... and so on. Each cpu type needs a binary that is compatible with that cpu.
Quote:
Another edit:
Some architectures support the emulation of other architectures even if the instruction sets are not compatible but emulation isn't a very good option unless it is the only option.
|
It depends. If you had x86 vs. amd64 in mind, note that in this case it's not emulation. Amd64 can run x86 object code
natively, you just need to take care to make available all the needed libs. For example, you can run a 32 bits opera browser on gentoo for amd64, but portage will then install the basic 32 bits libs (which are available on gentoo via its package manager) because a 32 bits opera binary can't link against the 64 bits versions that are already installed on the system.
In terms of portability of binary objects, the best you can do is to compile for 32 bits, and link statically when possible. This way, you will ensure that your binary file will run into x86 and x86_64 at least. Make sure you don't enable exotic features like -msse3 and the like, or your binaries will fail to run on any cpu that has not that extension.