Code Like Zell

How to modify the GNU linker’s default search path

A couple of weeks ago I hit multiple snags on my first attempt at installing memcached from source code on CentOS, hence the tutorial, “How to install memcached.” The fact that users found the tutorial by searching Google for the exact error messages in my post reassured me that I wasn’t just being an idiot. Here I will address a very similar problem and provide a once and for all solution.

I installed GNU’s Scientific Library and Ruby’s wrapper for GSL on Ubuntu and OS X without any problems. Next up: CentOS. The install appeared to complete successfully, but a require ‘gsl’ from irb showed otherwise:

LoadError: libgsl.so.0: cannot open shared object file: No such file or directory

I located libgsl.so.0 in /usr/local/lib; so once again I have a problem with the linker finding a shared library. The way I fixed this during the memcached install was to add the --rpath linker flag during the build. But I don’t wan’t to keep running into this in the future, so I decided to add /usr/local/lib to ld’s default search path, here’s how:

Open /etc/ld.so.conf and make sure there is a single line that reads:

include ld.so.conf.d/*.conf

Then, from bash prompt:

echo "/usr/local/lib" >> /etc/ld.so.conf.d/loc_lib.conf
/sbin/ldconfig

That should do it.

If you would like to learn more on the subject, this is the only good documentation I have found on Shared Library Search Paths.

Thanks for reading, now find something to do at  GoLark.com


2 Comments

Thanks a lot! This helped me after a long fight with the rb-gsl on Ubuntu!

Posted by Johan on 12 April 2008 @ 3pm

Glad I could help!

Posted by lou on 29 June 2008 @ 8pm

Leave a Comment

Broaden your vocabulary with Genius, Ruby, and Dictionary.com Create a sick game with Processing