How to modify the GNU linker's default search path

Posted: 03/28/2009

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 the problem is 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 in your editor and make sure there is a single line that reads:

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

Then, from your shell 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 best documentation I have found on Shared Library Search Paths.

About Me

I'm a skier, web developer, entrepreneur, freelancer, and all around stand-up guy living in Manhattan. This is me, repping one of my favorite shirts...

Follow me on twitter or send me an email.

All Posts