【问题标题】:extending default lib search path in ubuntu在 ubuntu 中扩展默认的 lib 搜索路径
【发布时间】:2012-02-27 10:03:32
【问题描述】:

如何在 ubuntu 中扩展默认的 lib 搜索路径(在某种程度上它也是持久的)?不,我确实想要导出基于 LD_LIBRARY_PATH 的临时解决方案,而是想通过某种方式扩展默认的 lib 搜索路径?

在 google-ing 时,我发现了一些信息,在 ubuntu 中,默认搜索路径位于 /etc/ld.so.conf.d 中,但编辑 libc.conf 不会扩展默认路径..所以我认为要么我做错了,要么缺少某些东西......

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

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

【问题讨论】:

    标签: linux shared-libraries ubuntu-11.04


    【解决方案1】:

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

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

    运行之后

    sudo ldconfig
    

    无需更改 libc.conf。

    【讨论】:

    • 谢谢!请注意,仅在扩展名之前没有名称的“.conf”文件不起作用。
    【解决方案2】:

    使用sudo,而不是root

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

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

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

    $ sudo ldconfig
    

    【讨论】:

      猜你喜欢
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-25
      • 2012-11-26
      • 2015-02-03
      相关资源
      最近更新 更多