I am using g++(under linux) to compile a piece of c code. The compiled executable file works good on linux. But it doesn`t run on unix(SunOS). How to make the compiled file runs on both Unix and Linux? Thank you.
The POSIX.1 standard guarantees compatibility on source code niveau. This is—every program that is written to use the POSIX.1 APIs is guaranteed to compile and run on any POSIX platform. POSIX does not and did never guarantee that binaries are portable between different platforms, even if all of them are compliant.
Do not assume that you can execute the same binary on different platforms. While there are some toolkits that provide varying levels of emulation, this doesn't alway work.
For the special case of executing Linux binaries, there are some solutions, like lxrun for Solaris or the builtin system-call translation-layer the maps Linux to FreeBSD system calls on FreeBSD.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With