Setting up OpenSolaris as development platform


First, you need an installation of OpenSolaris. It shouldn't be too hard to install. I will assume that you have OpenSolaris 2009.06 or newer. It needs a primary bootable partition with a size of at least 4GB.

For OpenSolaris, there are two major C/C++ compiler. SunStudio is the official Sun compiler, which is used to compile all the stuff for Solaris. Then there is GCC, too. In this posting, I will describe how to install both and use them for your development.


The SunStudio IDE is based on Netbeans. The compiler comes packaged with it. The languages supported by default are C, C++, and Fortran. For more features and advertisment, visit:

You can install two versions on OpenSolaris: SunStudio 12 update 1, or SunStudio Express. The two packages you have to install are "sunstudio12u1", or "sunstudioexpress", respectively.

There exists a meta-package "ss-dev", which will install sunstudioexpress and some useful tools, like GNU Make, Java 6, Flex. For full list see end of article.


To install GCC and the other GNU tools, you can install the meta-package "gcc-dev". It will, too, install additional packages. For full list see end of article.

Install both

My advice is to install both meta-packages, ss-dev and gcc-dev. If you have ss-dev installed, gcc-dev will just install GCC, Binutils, and GDB. You can use GCC in the SunStudio IDE, too.

You could install a different IDE, like Netbeans, Eclipse, or any other IDE, but the SunStudio IDE is better integrated in OpenSolaris.

So, to install both, run: pfexec pkg install ss-dev gcc-dev
It will use about 315MB.

Next Steps

Now you have two compilers installed, and a nice IDE, too. Let the development begin! Wait, there might be some libraries you want to use, which are not installed by default. I'll write about that, and other stuff, in the next article. You can just start SunStudio via "/opt/SunStudioExpress/bin/sunstudio" and play a bit with the IDE. I usually add it to the application menu or somewhere in the gnome panel.

Coming with SunStudio, there is dbx, a source-level debugging tool. OpenSolaris comes with mdb, a modular debugger. I haven't done much with it, but I will try them and describe how to use them later.

See ya..

Full list of packages installed by ss-dev:

Java 6: SUNWj6dmo, SUNWj6cfg, SUNWj6rtx, SUNWj6man, SUNWj6dvx, SUNWj6dmx, SUNWj6dev
Versioning tools: SUNWsvn, SUNWmercurial, SUNWcvs
Libraries: SUNWneon, SUNWapr13, SUNWapu13, SUNWarc
GNU development tools: SUNWgnu-automake, SUNWgm4, SUNWaconf, SUNWlibtool, SUNWgmake, SUNWbison, SUNWflexlex
Header files: SUNWhea
Compiler + IDE: sunstudioexpress

Full list of packages installed by gcc-dev:

Versioning tools: SUNWsvn, SUNWmercurial, SUNWcvs
Libraries: SUNWneon, SUNWapr13, SUNWapu13, SUNWarc
GNU development tools: SUNWgnu-automake, SUNWgm4, SUNWaconf, SUNWlibtool, SUNWgmake, SUNWbison, SUNWflexlex
Header files: SUNWhea
Compiler: SUNWgcc, SUNWbinutils, SUNWgdb

Richard Marks:
Cool! Thanks for the info!
I'll have to try that when I go back to my new home in TX. :D
I don't have any spare hdd where I'm located right now, otherwise I would try it right now.

First Project

This is a short description about how to work with Sun Studio. If you already know Netbeans or a similar IDE, you probably don't need to read this.

The first image is what you will probably see after you start Sun Studio (via /opt/SunStudioExpress/bin/sunstudio or via menu).

To create a project, click on the "New Project" button, or select "File->New Project" from the menu, or press ctrl+shift+N. The second image shows you the dialog box that appears. Select the "C/C++" Category and then the "C/C++/Fortran Application" entry.

The third image shows you the next step. Choose some name for your project. Sun Studio will save them in $HOME/SunStudioProjects/ by default. Then, click on "Finish".

Right click the "Source Files" folder beneath your newly created project and select "New->Main C File". Then you will see a dialog like the fourth image. You can name it if you wish, but I just clicked on "Finish".

Now you can start coding. I added a small "Hello there!" printf, as you can see in the fifth image.

To compile and run the Application, click on the "Run Main Project" button, or choose "Run->Run Main Project" in the menu, or press F6. This will compile the project and run the resulting executable. It automatically starts a terminal for console output, and keeps it open after program execution, until you press Enter. You can see it on the last image.

If you got this far, I congratulate you for your first Sun Studio project. It got compiled with the Sun compiler and the dmake tool. I'll show you how to change it to GCC, if you want to use it.

Using GCC

If you want to use GCC for your project, you just have to select it for your project. To do this, right click on your project and select "Properties", all the way down at the bottom, or select "File->Project Properties" from the menu.

In the new dialog that pops up, select the "Build" category. To the right, you can select the "Tool Collection" for each of the configurations. You can add a new configuration, if you want, or just change the collection for the active one. It should have three entries in the list, as seen in the attached image.

GCC uses the GCC tools, namely the GCC compiler and GNU make, etc.

SunStudioExpress and SunStudio should be identical, unless you have installed a different version of Sun Studio, too. "SunStudio" is the default selection for new projects.

After you changed the Tool Collection, you have to recompile your project. Just press F6 and it should build and execute. Each Tool Collection gets it's own output directory, so you don't have to think about old object files from different compilers.

Richard Marks:
Hey that is pretty cool man!
I can't wait to be able to try it all out!
Thanks for contributing!


[0] Message Index