Jump to content
  • Advertisement
Sign in to follow this  
Yezu

Shared Libraries Problem...

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 hydroo
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

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by Yezu
Isn'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 this post


Link to post
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 this post


Link to post
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 Yezu
Isn'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
Why LD_LIBRARY_PATH is bad

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!