This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: paths for headers and libraries


David Byron wrote:
> 

David, please do two things if you don't want to seriously annoy people:
set your mail client to wrap at somewhere around 70-75 columns, and stop
snipping attributions.

> > The linker on your system has a default list of directories
> > which it looks for libraries in.  This default list is
> > compiled directly into the linker.
> >
> > ld --verbose | grep SEARCH
> >
> > SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib);
> > SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/i386-redhat-linux/lib);
> >
> > Read the gcc and ld documentation for ways of changing the
> > search path.  Using the -L flag is one way to do it.
> 
> I should have asked another question the first time.  Does this setup
> cause other people grief -- looking in /usr/local first for headers
> but /usr first for libs?  From looking at binutils/ld/genscripts.sh,
> this seems to be the default.  If not, I guess I did something
> out-of-the-ordinary when installing my duplicate stuff in /usr/local.
> Since I think looking in /usr/local first is right, I'll move this
> to the binutils list if it goes much further.

Yes, this bit me recently too, when I built GCC 3.0.3 on Cygwin, and my
builds kept breaking with missing symbols until I figured out (after
several hours' frustrating experimentation) that it was still linking
with the old libstdc++ from GCC 2.95.3.

It hadn't occurred to me that the same problem would show up on Linux --
for some reason I just took it for granted that this was a Cygwin
problem -- but now that you mention it, it turns out the link search
path is the same on Linux. I have the same setup here on Linux, GCC
3.0.3 installed into /usr/local and pre-empting the original
2.95.something in /usr. Presumably the reason the problem never showed
up on Linux is that here I'm using the dynamically linked libstdc++
(while 2.95.x was still using the static one), while on Cygwin both
versions use a static library. But if I install a new version of some
other (statically linked) library in /usr/local/lib that still has an
old version in /usr/lib, I guess I'll run into it again.

At the moment I'm using $LIBRARY_PATH to work around this, but that's an
annoying wart and anyway it isn't a global solution (I have to set the
variable in my .bashrc and root's, and then what if I give somebody else
an account?). Using -L in makefiles isn't an option, because it probably
won't be appropriate to other systems.

Can anybody explain a general solution to this? A way of changing the
link search path globally and permanently? I've searched the ld docs but
can't find anything relevant.

-- 
Ross Smith ...................................... Auckland, New Zealand
r-smith@ihug.co.nz ......................... http://storm.net.nz/~ross/
  "We need a new cosmology. New gods. New sacraments. Another drink."
                                                       -- Patti Smith


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]