Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have build some libraries from sources, and the files after make install are in /usr/local/lib

For example, in my case I have the file libodb-2.2.so which is in this directory.

However when I launch the executable that has linked with libodb, I got the error: error while loading shared libraries: libodb-2.2.so: cannont open shared object file: No such file or directory.

Does it mean that I have build my executable not correctly ? or should I indicate the system that there maybe some interesting libs in the folder /usr/local/lib also ?

I'm using Ubuntu 12.04, Linux kernel 3.2.0-38-generic.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

For the current session you can

export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib

or to make the change permanent you can add /usr/local/lib to /etc/ld.so.conf (or something it includes) and run ldconfig as root.

If you're still having problems, running ldd [executable name] will show you the libraries it's trying to find, and which ones can't be found.

share|improve this answer

If you've already run ldconfig after building the library, keep reading. If not, read aboout ldconfig first.

/usr/local/lib might not be in the library path that ldconfig uses. You can just do this:

ldconfig /usr/local/lib

And the stuff should be added to the linker cache, but it is probably better to add the path properly. Make sure you have a /etc/ld.so.conf.d directory. If so add a file (call it "usr-local.conf", or whatever), and put one line in it:

/usr/local/lib

Now run ldconfig. If you don't have the ld.so.conf.d directory, you should have a /etc/ld.so.conf file and you can add that line to the end of it.

share|improve this answer
    
I've added a custom.conf file to /etc/ld.so.conf.d then sudoed ldconfig to take it into account and my executable can start now. –  Stephane Rolland Mar 13 '13 at 14:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.