There are two possible C/C++ compilers available for Solaris.
GNU C/C++. This is the compiler most often used on Linux. It is often referred to as 'gcc'. It is first class compiler and is available for both Solaris on SPARC and Solaris on X86. Once installed this compiler is always executed using the
Solaris Studio. This is Oracle's own compiler. It was previously called Sun Studio. Some say that it will produce faster code than gcc especially on SPARC. If you choose this compiler prepare for some warnings when you compile someone else code. This is because most code these days has been developed using the gcc compiler and the gcc compiler lets the C/C++ developer get away with more dirty tricks without flagging them as such. The Solaris Studio compiler on the other hand is a lot more chatty about what is sees as bad or even non-standard coding style. Just ignore such warnings from Solaris Studio compiler. Back many, many years ago this compiler would cost you money. Today it is a free download from Oracle under the "Oracle Solaris Studio OTN Developer License Agreement" which - although not a totally "free" license" - won't be limiting for 99.9% of users. Once installed this compiler is always executed using the
For most cases the GNU C/C++ compiler is just fine and is all you need.
It is already installed but it lives in
/usr/sfw/bin. The most common mistake people make is to assume it is not installed because they can't find it on their PATH. Make
/usr/sfw/bin part of your PATH after your other elements on your PATH.
It is not installed by default. Follow the instructions found here. You do not have to be root in order to install it.
GNU make is also installed by default in Solaris 10. It too lives in
/usr/sfw/bin and is called
It is not installed by default. By far the easiest is to use IPS to install it using the commands below (while being root or other superuser):
pkg install pkg://solaris/developer/build/gnu-make
pkg install pkg://solaris/developer/build/make
pkg install pkg://solaris/developer/gcc-45
pkg install pkg://solaris/system/header
pkg install pkg://solaris/developer/build/autoconf
pkg install pkg://solaris/developer/build/automake-110
This will give you all the tools you typically need to build various open source software packages.
Note that some of the packages have a version number in the package name itself, e.g.
gcc-45. You may be able to find even later versions in the package repository, for example for Solaris 11.2 Beta you'll find you have a choice of GCC 4.5, 4.7 or 4.8. The same applies to automake which is now also available in v1.11.
It is not installed by default. Follow the instructions found here. You can choose to to install via IPS (the easiest I think, although it does require you to add another IPS repository as well as a certificate ... all of which is documented on the link). You can also install via a tarball in which case you do not have to be superuser.
General recommendations when building software packages on Solaris
So you grabbed a software package from the Internet and now want to build it on Solaris ? Here are some general recommendations:
GNU tar to unpack, don't use Solaris' own
tar. So do
gtar xf foo.tar rather than
tar xf foo.tar or whatever. Yes in 99.99% of the cases Solaris' tar will work just fine for you but there are some subtle differences between the two for example if the tar file contains soft links.
GNU make rather than Solaris'
make For example when you are told to do this:
make all then instead do
MAKE=gmake gmake all.
You will generally have less trouble using GNU C/C++ to build rather than Solaris Studio because chances are that the makefiles and the compile options etc have only been tested with GNU C/C++ compiler.
Probably more to add to this list. Keep those comments coming.