For When You Can't Have The Real Thing
[ start | index | login ]
start > gcc on solaris

gcc on solaris

Created by dave. Last edited by dave, 19 years and 41 days ago. Viewed 4,338 times. #2
[diff] [history] [edit] [rdf]
These are some potentially useful things to know when fighting with gcc on Solaris (Solaris 8 in my case). I keep having to go off and learn this, so this time I'm writing the damn information down.

configure --prefix=/where/to/stick/it

Sometimes you might think you would like an organized /usr/local or /opt or /tools tree rather than the unholy mess in /usr/local that one generally gets. Most of the time you can tell tools where to install themselves by invoking configure as above, and it will stick it where you tell it to.

This can have some unpleasant side-effects on future tool builds (being unsuccessful at) finding things, and since some configures are not flexable enough that you can tell it --with-tool=/place/where/tool/is. So you have to set up the environment ahead of time with some of these variables.


These files are searched, as if they are paths, for include files which are not found in other ways. CPATH is always searched, the other three are only searched for the relevant language. This is useful because when you have installed some library in /where/to/stick/it, you can set CPATH to /where/to/stick/it/include and presto, configure should be happier.


A path which is searched at run time for shared libraries. Now theoretically your programs should be told at linktime where their libraries will be at runtime, but this doesn't always work. So you have to give the dynamic linker some hints. For our example, you'll probably need to set LD_LIBRARY_PATH to /where/to/stick/it/lib for the right magic to happen.


A path which is searched at link time for libraries. This seems to get ignored for several reasons I don't understand.


Generally, a way of forcing ld to do what you want when libtool doesn't. ld will be evaluated as if it was invoked like this:

ld $LD_OPTIONS (actual parameters)

More specifically, it is a way of bulldozing on directories for ld to search. This _always_ works, even when the other 'hint' methods above don't. The worst offender is when you get link errors claiming -lgcc and -lstdc are not found -- in my case, I have to set


to get around this. Another use for this variable is to glue the runtime library locations into the library being linked; ie


If you are going to pass more than one flag through LD_OPTIONS, keep in mind you probably need to protect the spaces with quotes -- ie

LD_OPTIONS="-L/opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3 -R/where/to/stick/it/lib"

Bibliography: much of this stuff was learned from a page describing >>gcc's environment variables (you might be interested in all of the >>gcc documentation) plus some reading of the man page for ld(1) on Solaris 8.

no comments | post comment
This is a collection of techical information, much of it learned the hard way. Consider it a lab book or a /info directory. I doubt much of it will be of use to anyone else.

Useful: | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt