linux下如何设置环境变量LD_LIBRARY_PATH [英] How to set the environmental variable LD_LIBRARY_PATH in linux
问题描述
我先执行了命令:export LD_LIBRARY_PATH=/usr/local/lib
然后我打开了.bash_profile
文件:vi ~/.bash_profile
.在这个文件中,我把:
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
然后如果终端关闭并重新启动,输入 echo $LD_LIBRARY_PATH
不会显示任何结果.
Then if the terminal is closed and restarted, typing echo $LD_LIBRARY_PATH
displays no result.
如何永久设置路径?
推荐答案
你应该添加更多关于你的发行版的细节,例如在 Ubuntu 下正确的方法是添加一个自定义的 .conf
文件到/etc/ld.so.conf.d
,例如
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.
保存并运行 sudo ldconfig
以使用此库更新系统.
Save and run sudo ldconfig
to update the system with this libs.
这篇关于linux下如何设置环境变量LD_LIBRARY_PATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!