| Home > Geek stuff > Sun Resources > Developing Software on Solaris | http://www.kevininscoe.com/geek/sun/compilesun/ |
| Last updated: 410 day(s) ago (Sun Jul 19 11:28:27 2009) | Thu Sep 2 20:59:37 2010 |
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... ccThis 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:
checking whether the C compiler (cc ) works... no
configure: error: installation or configuration problem: C compiler cannot create executables.
# CC=gcc;export CCor
# setenv CC gccThere are other reasons for this error to occur. Check the output of your "config.log" file. If you see:
configure: cc: not foundThis indicates that that configure is indeed looking for the Solaris compiler.
# rm -f config.cache
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.Please send comments, updates or corrections to kevin [at] inscoe {dot} org.
This site is Lynx friendly!
![]() |
![]() |
![]() |
| 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.