# Shared Libraries Problem...

This topic is 3712 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi! I'm totally lost when it comes to shared libraries on Linux. I know that on win32, when I put the .dll file in the same folder as the executable it will be found and used. How do I achieve same functionality with .so files on Linux? thanks :)

##### Share on other sites
LD_LIBRARYPATH points to locaations where ld has to search for libs
and
/etc/ld.so.conf and /etc/ld.so.conf.d/* contain more directories to search in.

the most common place where to find libs is /usr/lib.

e.g. you could run your program like this: $LD_LIBRARYPATH=/where/ever ./myprogram #### Share this post ##### Link to post ##### Share on other sites Most libraries just move any library files into /usr/lib. This is frequently done in the "install" target of a makefile. #### Share this post ##### Link to post ##### Share on other sites Quote:  Original post by hydrooLD_LIBRARYPATH points to locaations where ld has to search for libsand/etc/ld.so.conf and /etc/ld.so.conf.d/* contain more directories to search in.the most common place where to find libs is /usr/lib.e.g. you could run your program like this:$ LD_LIBRARYPATH=/where/ever ./myprogram

It's LD_LIBRARY_PATH.

And, if you add a new line to /etc/ld.so.conf or drop a text file in /etc/ld.so.conf.d, you will need to rerun ldconfig to regenerate the search cache file (/etc/ld.so.cache).

The default place ld-linux.so (the dynamic linking loader) looks is usually /usr/lib and then /lib (see ld.so(8) for documentation).

##### Share on other sites
If you are using gcc (or g++) you can use "-Wl,-rpath=/The/Search/Path" to put the search path directly into the executable.

##### Share on other sites
Quote:
 "-Wl,-rpath=/The/Search/Path"

It would seem it's exactly what I'm looking for, thanks!

Quote:
 It's LD_LIBRARY_PATH.

Isn't LD_LIBRARY_PATH broken, and should not be used?

##### Share on other sites
Quote:
 Original post by YezuIsn't LD_LIBRARY_PATH broken, and should not be used?

I'm not aware of any such problem and we use it all the time in both commercial and free software products I work on. Do you have a link or reference to anything exaplaining the breakage and why we should avoid it? If it's true, I may have quite a lot of work to do in the next little while...

##### Share on other sites
If you throw LD_LIBRARY_PATH into google, half the results on the first page are about how to set it, and the other half are explanations of why you shouldn't.

##### Share on other sites
This is a good tutorial about libraries in Linux:
Static, Shared Dynamic and Loadable Linux Libraries

Quote:
Original post by Bregma
Quote:
 Original post by YezuIsn't LD_LIBRARY_PATH broken, and should not be used?

I'm not aware of any such problem and we use it all the time in both commercial and free software products I work on. Do you have a link or reference to anything exaplaining the breakage and why we should avoid it? If it's true, I may have quite a lot of work to do in the next little while...

LD_LIBRARY_PATH - just say no

1. 1
2. 2
3. 3
frob
12
4. 4
5. 5
Rutin
10

• 13
• 14
• 65
• 14
• 15
• ### Forum Statistics

• Total Topics
632130
• Total Posts
3004284

×