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

。_饼干妹妹 提交于 2019-12-10 12:32:02

问题


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.


回答1:


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).



来源:https://stackoverflow.com/questions/12234010/gcc-linked-libraries-in-usr-local-lib-are-not-found-but-etc-ld-so-conf-d-lib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!