1

May I know if I can cross compile the Solaris x86 library from Solaris sparc server?

The source code is mainly in C++ (some C). I need to use the Solaris C++ compiler CC to compile. I understand that some compile or link flags are different between sparc and x86. I have done a check to make sure that the flags I used are common.

Is it possible to simply copy the library compiled in sparc to x86? Or I need to apply specific flag during compiling and linking?

Thanks,

ygao
  • 127
  • 9

3 Answers3

1

The Sun/Oracle Studio C++ compilers do not support cross-compilation. You would need to use another compiler that does, like a specially built gcc.

Simply copying the library can't work - SPARC and x86 are very different instruction sets, with no binary compatibility between the two.

alanc
  • 4,102
  • 21
  • 24
0

Oracle Sun Studio C++ compiler (CC) has --xarch option with big variety of architectures. There are: sparc, amd64, pentium_pro and various extensions/modifications. This flag should be provided for both compiler and linker if you compile and link in separate steps.

You can verify target architecture with file command; e.g:

bash-3.2$ file /usr/bin/CC
/usr/bin/CC:    ELF 32-bit LSB executable 80386 Version 1 [FPU], dynamically linked, stripped

Please, refer to CC manual for details: Sun Studio 11 C++ Man Page

0

Even if you could cross compile the Solaris libraries on SPARC for x86, it would seem a lot simpler to just install the x86 compilers and libraries. The interdependencies of these libraries is probably so complex that such a project would probably not work.

What's preventing you from just downloading and installing the Studio software on x86 Solaris?

rchrd
  • 115
  • 4
  • Hi rchrd, thanks for your answer. I am working on compiling the library on x86 Solaris now. Request the access rights and install the compiler on x86 Solaris need to cross over some bureaucratic barrier... – ygao Jun 02 '11 at 05:26
  • For those who come here: What bureaucratic barrier?. Solaris Studio is a free download. So is Solaris itself as long as you do not use it for development. Fire up a VirtualBox on your Windows workstation, put Solaris on it and you have a Solaris X86 development host ! – peterh Jul 24 '13 at 22:34