Linux 在 ubuntu 中扩展默认的 lib 搜索路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9151491/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:24:08  来源:igfitidea点击:

extending default lib search path in ubuntu

linuxshared-librariesubuntu-11.04

提问by P M

How can i extend default lib search path in ubuntu(in a way that it is also persistent) ? no, I do notwant export LD_LIBRARY_PATH based temporary solution, rather some way to extend the default lib search path ?

我如何在 ubuntu 中扩展默认的 lib 搜索路径(以它也是持久的方式)?不,我希望出口LD_LIBRARY_PATH基于治标不治本,而一些方法来扩展默认的lib搜索路径?

while google-ing, I cam across some info, that in ubuntu the default search path resides in /etc/ld.so.conf.d, but editing libc.conf does not extended the default path.. so i think either i am doing it wrong, or something is missing...

在 google-ing 时,我发现了一些信息,即在 ubuntu 中,默认搜索路径位于/etc/ld.so.conf.d 中,但编辑 libc.conf 并没有扩展默认路径.. 所以我想要么我是做错了,或者缺少什么......

the edited libc.conflooks like...

编辑后的libc.conf看起来像...

# libc default configuration
/usr/local/lib:/path_to_my_libraries/lib

采纳答案by isti_spl

create (as root) a new file in /etc/ld.so.conf.d/containing, the new path. For example:

创建(作为 root)一个/etc/ld.so.conf.d/包含新路径的新文件。例如:

sudo echo "/path-to-your-libs/" >> /etc/ld.so.conf.d/your.conf

after that run

在那次跑步之后

sudo ldconfig

No need to change libc.conf.

无需更改 libc.conf。

回答by Serge Stroobandt

Using sudo, without becoming root

使用sudo, 而不会变成root

This will create a your.conffile with a reference to /path-to-your-libs/:

这将创建your.conf一个引用以下文件的文件/path-to-your-libs/

$ echo '/path-to-your-libs/' |sudo tee -a /etc/ld.so.conf.d/your.conf

Do not forget to finish off with a dynamic link library cache refresh:

不要忘记以动态链接库缓存刷新结束:

$ sudo ldconfig