0 down vote favoriteI tried to compile some C code to get object file from a shell prompt:$cc a.c But this gives me the following error:/usr/ucb/cc: language optional software package not installedHow can I compile C code?
It is unfortunate that sun ever shipped /usr/ucb/cc; you would thinkit was compatible with SunOS 4; instead it compatible with some veryold version of 4.2 but it also required the installation of theSunPro (Now Solaris Studio) compilers.
First, you should probably remove /usr/ucb from your PATH as this directory is quite obsolete now. It was meant to ease people migrating from SunOS 4 to Solaris 2 a couple of decades ago but doesn't make much sense these days. Especially this cc commands which set specific flags to compile BSDish code.
Second, all current Solaris releases comes with a C compiler out of the box but it is located in a directory which might not be in your PATH, /usr/sfw/bin and is named gcc (Gnu compiler).
use /usr/sfw/bin/gcc
or
PATH=$PATH:/usr/sfw/bin
gcc
Alternatively, you might have already installed (or you can install) the Solaris Studio compiler. In that case, its path would be <installation-dir>/bin/cc (eg: /opt/SUNWspro/bin/cc or /opt/SolarisStudio11/bin/cc etc ...)