如何在linux中设置环境变量LD_LIBRARY_PATH [英] How to set the environmental variable LD_LIBRARY_PATH in linux

查看:1284
本文介绍了如何在linux中设置环境变量LD_LIBRARY_PATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我先执行了命令: export LD_LIBRARY_PATH = / usr / local / lib



然后我有打开 .bash_profile 文件: vi〜/ .bash_profile
在此文件中,我将:

  LD_LIBRARY_PATH = / usr / local / lib 
export LD_LIBRARY_PATH

然后,如果终端被关闭并重新启动,键入 echo $ LD_LIBRARY_PATH 显示没有结果。



如何永久设置路径?

解决方案

您应该添加更多有关您的发行版的详细信息,例如在Ubuntu下,正确的方法是将自定义的 .conf 文件添加到 /etc/ld.so.conf.d ,例如

  sudo gedit / etc你应该写的文件里面的/ld.so.conf.d/randomLibs.conf 

完整路径到包含您要添加到系统的所有库的目录,例如

  / home / linux /记住只添加路径到目录,而不是文件的完整路径,所有这些都是lib里面那个拍h将被自动索引。



保存并运行 sudo ldconfig 以使用此libs更新系统。 >

I have first executed the command: export LD_LIBRARY_PATH=/usr/local/lib

Then I have opened .bash_profile file: vi ~/.bash_profile. In this file, I put:

LD_LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH

Then if the terminal is closed and restarted, typing echo $LD_LIBRARY_PATH displays no result.

How to set the path permanently?

解决方案

You should add more details about your distribution, for example under Ubuntu the right way to do this is to add a custom .conf file to /etc/ld.so.conf.d, for example

sudo gedit /etc/ld.so.conf.d/randomLibs.conf

inside the file you are supposed to write the complete path to the directory that contains all the libraries that you wish to add to the system, for example

/home/linux/myLocalLibs

remember to add only the path to the dir, not the full path for the file, all the libs inside that path will be automatically indexed.

Save and run sudo ldconfig to update the system with this libs.

这篇关于如何在linux中设置环境变量LD_LIBRARY_PATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆