Linux下設置程序可以在當前目錄下查找so文件

環境:Vmware Workstation;CentOS-6.4-x86_64

說明:

1、爲了讓Linux能在本目錄下找到so文件,需要修改.bash_profile。

2、在.bash_profile的最後位置添加代碼:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.

3、也可以把so文件放到linux的系統目錄下:/usr/lib/

設置步驟:

1、進入到宿主目錄cd:

[negivup@negivup mycode]$ cd

2、打開並編輯.bash_profile文件:

[negivup@negivup ~]$ vim .bash_profile 
3、在PATH中加入代碼“:.”:
<div># .bash_profile</div><div>
</div><div># Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi</div><div>
</div><div># User specific environment and startup programs</div><div>
</div><div>PATH=$PATH:$HOME/bin:.</div><div>
</div><div>export PATH</div><div>
</div><div>export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.</div>
4、保存並退出:
:wq
5、使更改立即生效“. .bash_profile”:
[negivup@negivup ~]$ . .bash_profile


PS:根據傳智播客視頻學習整理得出。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章