Library paths

Library paths

Post by n.. » Sun, 31 Dec 1899 09:00:00



How does linux (or maybe bash?) know which directories to look in for
library files when it loads up a program? On other systems it seems to be
done by setting the LD_LIBRARY_PATH enviroment variable but in linux this
has no effect. Surely I don't have to place new libraries in either /lib
or /usr/lib because these are the only ones it looks in and this can't be
changed?

NJR

 
 
 

Library paths

Post by jik » Sun, 31 Dec 1899 09:00:00



> How does linux (or maybe bash?) know which directories to look in for
> library files when it loads up a program? On other systems it seems to be
> done by setting the LD_LIBRARY_PATH enviroment variable but in linux this
> has no effect. Surely I don't have to place new libraries in either /lib
> or /usr/lib because these are the only ones it looks in and this can't be
> changed?

LD_LIBRARY_PATH should work.  You can also edit /etc/ld.so.conf

 
 
 

Library paths

Post by NF Steve » Sun, 31 Dec 1899 09:00:00



>How does linux (or maybe bash?) know which directories to look in for
>library files when it loads up a program? On other systems it seems to be
>done by setting the LD_LIBRARY_PATH enviroment variable but in linux this
>has no effect. Surely I don't have to place new libraries in either /lib
>or /usr/lib because these are the only ones it looks in and this can't be
>changed?

You can change the default locations where the loader looks for
shared libraries by editing /etc/ld.so.conf and then running
ldconfig. This is a system wide setting and will affect all
users. Alternatively the LD_LIBRARY_PATH environment variable
should work in the way you expected it to, though there
are a couple of points to note. LD_LIBRARY_PATH is ignored
for programs which are setuid or setgid. If your program
is in aout format then the relevant environment variable
is LD_AOUT_LIBRARY_PATH. Check the man page for ld.so
(the dynamic linker) for details.

Norman

 
 
 

Library paths

Post by Errin Watusika » Sun, 31 Dec 1899 09:00:00



Quote:> LD_LIBRARY_PATH should work.  You can also edit /etc/ld.so.conf

I think you also have to get the superuser to run ldconfig; see the man
page.

There's also a LD_RUN_PATH; I've not yet understood the difference.

 
 
 

Library paths

Post by Leonard Even » Sun, 31 Dec 1899 09:00:00




> >How does linux (or maybe bash?) know which directories to look in for
> >library files when it loads up a program? On other systems it seems to be
> >done by setting the LD_LIBRARY_PATH enviroment variable but in linux this
> >has no effect. Surely I don't have to place new libraries in either /lib
> >or /usr/lib because these are the only ones it looks in and this can't be
> >changed?

> You can change the default locations where the loader looks for
> shared libraries by editing /etc/ld.so.conf and then running
> ldconfig. This is a system wide setting and will affect all
> users. Alternatively the LD_LIBRARY_PATH environment variable
> should work in the way you expected it to, though there
> are a couple of points to note. LD_LIBRARY_PATH is ignored
> for programs which are setuid or setgid. If your program
> is in aout format then the relevant environment variable
> is LD_AOUT_LIBRARY_PATH. Check the man page for ld.so
> (the dynamic linker) for details.

> Norman

And make sure you export the variable LD_LIBRARY_PATH after
setting it.
--


Dept. of Mathematics, Northwestern Univ., Evanston, IL 60208

 
 
 

Library paths

Post by NF Steve » Sun, 31 Dec 1899 09:00:00




>> LD_LIBRARY_PATH should work.  You can also edit /etc/ld.so.conf

>I think you also have to get the superuser to run ldconfig; see the man
>page.

>There's also a LD_RUN_PATH; I've not yet understood the difference.

The linker looks at LD_RUN_PATH when linking an executable against
shared libraries. It puts this value into the resulting executable
so that the executable will always look in these directories when
it is run.

Norman