[svlug] modify default directory search order for GCC

tony yu yutaotao at gmail.com
Tue Aug 8 12:05:51 PDT 2006


On 8/8/06, Fabrizio Bertocci <fabriziobertocci at gmail.com> wrote:
>
> On 8/8/06, tony yu <yutaotao at gmail.com> wrote:
> >
> > ...
> >
> > and it should be like that, as -L. puts the additional directory AFTER
> > the default order.
> >
> > and running mytest will still use /usr/libz.so even I export
> > LD_LIBRARY_PATH=. as it is already located during linking time.
> >
> > My question is, and hope, someone has seen it before,
> >
> > how do I make my exectuable use the one I desired (in current directory)
> > instead of the one at /usr/lib?
> >
>
>
> My take on this is that Linux doesn't do any pre-binding at compile time,
> but everything is resolved at run-time.
> You can ignore the fact that gcc is using your libz from /usr.
> The problem is the runtime.
> Did you try to give to LD_LIBRARY_PATH an absolute path instead of a
> relative path?
> What does 'ldd' shows after that?
> What happen if you 'hide' (temporarily) your /usr/libz.so? Does ldd see
> your local one?
> Try to change the search order from /etc/ld.so.conf and re-run ldconfig.
>
> Fabrizio
>

Thanks, you are saying that even gcc picks up /usr/lib/libz.so at linking
time, it does not matter as I can force it to use own libz.so at run-time?
but how? LD_LIBRARY_PATH won't work as it add the directory after the
default order unless there are no libz.so at those default directories.


if i hide the /usr/lib/libz.so, and given the -L. option, it should see the
> libz.so under current directory. However, it's not really practical as
> there might be libz.so under /usr/local/lib and it has higher order than
> current directory.
>

   if giving absolute path to   LD_LIBRARY_PATH  and then gcc it, it still
use the /usr/lib/libz.so
  btw, I don't think LD_LIBRARY_PATH impacts on the compiling and linking
time.

  my /etc/ld.so.conf does not even have /usr/lib included in.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://kenny.linuxmafia.com/pipermail/svlug/attachments/20060808/8bbbf6c9/attachment.htm 


More information about the Svlug mailing list