Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I 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 installed

How can I compile C code?

share|improve this question
What version of Solaris? Copy-paste the output of uname -a. Either you don't have a compiler or it's not in the default PATH; ask your admins. If you don't have a Sun compiler (or even if you have one), you can install GCC, possibly from a Sun software distribution. – Gilles May 6 '11 at 14:01

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



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 ...)

share|improve this answer

It is unfortunate that sun ever shipped /usr/ucb/cc; you would think it was compatible with SunOS 4; instead it compatible with some very old version of 4.2 but it also required the installation of the SunPro (Now Solaris Studio) compilers.

These compilers can be downloaded from


under the following license terms (quoted from the above page)

Provides perpetual no-cost license for production use and the development of commercial applications.

share|improve this answer

Many times it's worth it to put strange error messages regarding compiling through Google. When I did this, it seems Solaris doesn't come with a compiler out of the box and that is why you are seeing this. I'm not familiar with Solaris at all, but maybe you need to use its package management tools or something similar to actually install the compiler if this is the case.

share|improve this answer
Kind of obvious that a question tagged Solaris is about Solaris :-D – Let_Me_Be May 6 '11 at 13:57
Just now noticed it. Not enough coffee yet. Hehe. (edited my answer) – LawrenceC May 6 '11 at 14:13

Your Solaris installation doesn't have a compiler installed. Back in the 1900:s, Sun charged extra for their C compiler, and provided a stub "cc" command instead, just to remind you that the compiler is not installed.

To compile a file, you need to install a compiler for the same Solaris version (2.5.1?) and architecture (SPARC/sun4m?) that matches your operating system and computer hardware.

Read more at SunFreeware.com for free software that installs under /usr/local/.

If you take that open source/GNU road, you will probably need to install a lot of packages to satisfy dependencies before it works, but if you have the disk space it would probably be worth it.

Old versions of Sun's SparCompiler/Forte/SunStudio can be hard to obtain for your (supposedly) old machine, as they were typically licensed with node locked licenses, and you will not be able to buy a license for those obsoleted software packages any more.

share|improve this answer
This cc isn't a stub command to remind the compiler is not installed but was designed to ease recompiling code written for SunOS 4 (BSD) on Solaris 2 (System V). – jlliagre May 6 '11 at 14:45
/usr/ucb/cc: language optional software package not installed – MattBianco May 10 '11 at 8:12
It does indeed report that situation but my point was /usr/ucb/cc isn't "just a stub command designed to remind the compiler isn't installed" but a command with a different and specific purpose. – jlliagre May 10 '11 at 9:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.