Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc: linked libraries in /usr/local/lib are not found, but /etc/ld/so.conf.d/libc.conf lists it?

I've got a problem with shared libraries and gcc. At first I couldn't run my compiled program because I was getting the following error: gcc error while loading shared libraries.

I did some searching and found that this is because the shared library cannot be found. However I had already identified that the shared library is in /usr/local/lib, which AFAICT is a commonly used directory for shared libraries and should work from the get go.

I read that you can set LD_LIBRARY_PATH, which worked for me. However I do not wish to set this each time I want to run my program.

Further searching suggested editing ld.so.conf. When I looked in this it had the following:

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

Looking in the ld.so.conf.d directory shows me a range of files, including libc.conf. Inside this file is the following:

/usr/local/lib

So my question is, why do I need to manually set LD_LIBRARY_PATH when the ld.so.conf appears to use the libc.conf which includes /usr/local/lib?

Is there something that I'm missing here that must be configured first? Is there an option at compile time that I'm missing?

I should note that to compile, I had to specify the path to the library, I don't know if this is a symptom of my problem or normal behaviour.

I should also note that this is a concern for me for when I deploy my software on other systems. I would have thought that I should be able to put the .so in the appropriate place and install my program without messing with ld.so.conf.

I hope this is the proper forum for this question, I read the FAQ and I think it's ok.

Cheers.

like image 582
Metalskin Avatar asked Sep 02 '12 06:09

Metalskin


1 Answers

You should run ldconfig (as root) after every change of the directories configured via /etc/ld.so.conf or under /etc/ld.so.conf.d/, in particular in your case after every update inside /usr/local/lib (e.g. after every addition or update of some shared libraries there).

like image 116
Basile Starynkevitch Avatar answered Oct 15 '22 09:10

Basile Starynkevitch