vinaym
vinaym

Reputation: 467

Building c programs to target HP/Solaris OS

I have to write a C program can be run on HP UX & Sun Solaris. Do we have to build the executable on both machines? Is there a way to build on Linux say centos or ubuntu using standard compilers/linkers to ensure the executable will run on HP & Solaris machines?

Upvotes: 1

Views: 171

Answers (1)

FrankH.
FrankH.

Reputation: 18227

Both HP/UX and Solaris run on different CPU types, so it comes down to "what hardware do you need to support" (beyond: "which OS does it need to run on").

HP/UX first:

  • HP/UX supports HP's own old PA-RISC CPU architecture, for both 32bit and 64bit applications
  • HP/UX also (mainly, these days) runs on Intel Itanium CPUs

There's some sort of binary compatibility / shim layer (Aires) that I'm not particularly familiar with, but apparently it's possible to compile for some type of PA-RISC and the result can be run on Itanium-based HP/UX machines. In other words, for HP/UX, you have to decide whether the application needs to run on old 32bit PA-RISC, on later 64bit PA-RISC, or on Itanium, and then compile either on that target platform or in a suitably-configured crosscompile setup.

Solaris:

  • Solaris supports SPARC processors:
    in 32bit mode (for the kernel, up to and including Solaris 9), and
    in 64bit mode (from Solaris 7 onwards, and for kernel code mandatory from Solaris 10)
  • Solaris also supports Intel/AMD processors, both 32bit and 64bit mode (64bit requires Solaris 10 onwards)

Both on SPARC and x86 CPUs, Solaris can run 32bit applications even if the kernel itself runs 64bit, but there's no emulation/shim layers that'd allow you to run SPARC binaries on x86, or vice versa.

On Solaris, therefore, you've got to decide whether the application needs to run on SPARC and/or on x86, and second whether it needs to be compiled for 32bit or 64bit.

Creating crosscompilation setups for either Solaris or HP/UX, no matter which CPU type you're targeting, is challenging due to the size of the environment (they're both not exactly embedded OSses ...). In many cases, it'll likely be more cost effective / quicker to get started to buy a piece of older PA-RISC/Itanium or SPARC hardware, install HP/UX 11.x and Solaris 10, respectively, and compile natively. You'll also get the benefit of using the vendor compilers there, which both for Itanium and SPARC still generate faster code than GCC does.

Upvotes: 2

Related Questions