Home > Geek stuff > Sun Resources > Developing Software on Solaris http://www.kevininscoe.com/geek/sun/compilesun/
Last updated: 205 day(s) ago (Sun Jul 19 11:28:27 2009) Tue Feb 9 06:19:44 2010
Compiling & Developing Software on Sun Solaris 2.x

Compiling & Developing Software on Sun Solaris.

Note: This FAQ was originally created in 1995 after seeing question after question on the Sun Managers list concerning where to obtain a c/c++ compiler.
However since then I have been updating this document every once in a while to include programming tips as well.

Topics: [ Obtaining and installing a compiler | Troubleshooting | Programming tips | Additional resources ]

c/c++ porting and programming tips for the Solaris environment:

Solaris 2.x porting:

Consult the Solaris 2 Porting FAQ and The Solaris 2.x FAQ section 6 - Software Development

Recommended reading:

The "Goat" Book and Learning Autoconf and Automake.

2009-07-19: Several new resources have come out since the last update

To develop in GNU c/c++ projects you must be familiar with GNU Autotools. There is book due to be published in September 2009 on this subject. There is also an older tutorial on autotools.

I also recommend a knowledge of Libtool and the GNU Coding Standards.

For info on using GNU C compiler in general get the book Programming with GNU Software.

I also recommend Advanced Programming in the Unix Environment.

Obtaining and installing a c/c++ compiler for the Solaris environment:

In Solaris 10 the GNU c compiler and standard libraries come on the OS Companion Software disk or can be downloaded from the link below:

See Sun's
link about this.

If you install Sun's version of the GCC tools n Solaris 8, 9 or 10 they will install in directory /opt/sfw.

Relealize that Solaris 2.x does not come with a C compiler.
Free Software Foundation's GNU Compiler Collection (gcc) is recommended.
See my entry into the Sun Manager's FAQ (section 10.2) on how to do this here.

You can also download an already compiled version of gcc fromhttp://sunfreeware.com.

However if you need you can also purchase the Sun Studio(tm) (used to be called Visual Workshop or Forte)
a commercial development package fromSun.It contains a commercial C++ compiler.

In either case make sure you install the SUNWlibC, SUNWlibCf, SUNWlibm, SUNWlibms, SUNWscbcp, SUNWtoo, SUNWarc and SUNWhea packages as they contains the header files.

If you have loaded the SUNWbtool package you will find the /usr/ccs/bin CCS tools that are bundled with Solaris.

Check that you have installed the GNU and Sun recommended patches

Include the following environment variable in your login script:

LD_LIBRARY_PATH=/usr/lib:/usr/openwin/lib:/opt/gnu/lib:/opt/gnu/lib/gcc-lib/sparc-sun-solaris2.6/2.7.2.3

Of course this needs to point to your compiler library and the actual directory will vary.

An article (mirrored) on why setting LD_LIBRARY_PATH is bad. But hey sometimes you have to.

The default library path is hard-linked into:

	/usr/lib/ld.so.*	/usr/lib/libld.so.*
Some older notes on installing gcc on Solaris here.

Troubleshooting:

checking for gcc... cc
checking whether the C compiler (cc ) works... no
configure: error: installation or configuration problem: C compiler cannot create executables.
This means that configure is trying to use the Solaris /usr/ucb/cc compilerinstead of the GNU c (gcc) compiler. To fix this make sure you have the environment variable CC defined as gcc:
# CC=gcc;export CC
or
# setenv CC gcc
There are other reasons for this error to occur. Check the output of your "config.log" file. If you see:
configure: cc: not found
This indicates that that configure is indeed looking for the Solaris compiler.

Other kinds of problems such as libg++ issues can be resolved by reviewingthe install notes for
MySQL under section 2.12.3. Solaris Notes.

Remember configure uses a cache. So you sometimes have to remove the cacheand start over if you have made big changes to the compiler.
# rm -f config.cache

General GNU configure errors:

It is imperitive you have the SUNWbtools package installed otherwise youwill have to install the GNU make and library tools. If SUNWbtools isnot installed you will see errors like:
checking for ar... missing_arconfigure: error: No ar utility found.

If you wish to use the GNU make tools (and that's probably not a bad idea anyway) you can download a pre-compiled make for Solaris from either http://sunfreeware.com.

Some additional resources which may be of help:

The
Libg++ FAQ.

Using Splint for ANSI C.

Some resources for C programming.

An Introduction to C Programming.

Yahoo's C & C++ Directory

Programming in C FAQ

A tutorial on pointers and arrays in C

Please send comments, updates or corrections to kevin [at] inscoe {dot} org.

Sitemap:

[ Home | My professional site | Sig | Blogs | Podcasts | Where is Kevin? | Contact | Resume | More about Kevin ]
[ Geek | Weather | Radio | Aero | Electronics | Trains | GPS | Music | Travel | Movies | For sale | Photos ]
[ Mailing Lists | Quotes | Looking for a job? | Cheap gas? | Public files | Links | Changes ]
[ Inscoe Family | The Volt Company | Yellow Twister Hosting | Refuge Software ]
[ Central Florida Geeks | Central Florida Unix Professionals ]

Why are these pages black?

This site is Lynx friendly!

Current time in Deltona, Florida, United States [28.9002N 81.2419W | Grid: EL98jv] is Tue Feb 9 06:19:44 2010


Copyright © 1995-2005 Kevin P. Inscoe Viewable With Any Browser

This website and all original artwork and material is © copyright 2009 Kevin P. Inscoe. Other material is used under the "Fair Use" provisions of United States of America Copyright law, and all rights remain with the original copyright holders.