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


PS:根据传智播客视频学习整理得出。

你可能感兴趣的:(Linux编程(C/C++))