转载:http://blog.shenwei.me/solve-lib-not-found-in-linux/
本文帮助你解决在无root权限的linux系统上安装软件时候遇到的lib××× not
found的问题,并推荐一个Linux上良好的目录结构。
1. 安装软件到自己的软件目录。
缺乏的lib×××库大多都能在网上下载到源码,可自己下载安装。
下图是我在服务器上的目录结构,软件都安装在~/local/app里面,在~/local/bin里面分别建立软链接指向所安装软件的可执行文件;如果该软件里面的可执行文件太多,方便的做法是讲其所在目录加入到环境变量$PATH中。
├── data
│ ├── hg19
│ └── miRBase
├── local
│ ├── app
│ │ ├── mysql
│ │ └── R
│ └── bin
├── packages
├── projects
│ ├── miRNA
│ └── TLR
└── tmp
1
2
3
4
5
6
7
8
9
10
11
12
13
├──
data
│ ├── hg19
│ └── miRBase
├── local
│ ├── app
│ │ ├── mysql
│ │ └── R
│ └── bin
├──
packages
├── projects
│ ├── miRNA
│ └── TLR
└──
tmp
2. 设置环境变量
有的软件安装后只生成可执行文件,有的则产生一些库文件和头文件,则需要将其添加到相应环境变量中;share目录等可忽略。如下所示
# 可执行文件
export PATH=$HOME/local/app/bin:$PATH
# 静态链接库
export LIBRARY_PATH=$HOME/local/app/libevent/lib:$LIBRARY_PATH
# 动态链接库
export LD_LIBRARY_PATH=$HOME/local/app/libevent/lib:$LD_LIBRARY_PATH
# gcc头文件
export C_INCLUDE_PATH=$HOME/local/app/libevent/include:$C_INCLUDE_PATH
# g++头文件
export CPLUS_INCLUDE_PATH=$HOME/local/app/libevent/include:$CPLUS_INCLUDE_PATH
1
2
3
4
5
6
7
8
9
10
# 可执行文件
export PATH=$HOME/local/app/bin:$PATH
# 静态链接库
export LIBRARY_PATH=$HOME/local/app/libevent/lib:$LIBRARY_PATH
# 动态链接库
export LD_LIBRARY_PATH=$HOME/local/app/libevent/lib:$LD_LIBRARY_PATH
# gcc头文件
export C_INCLUDE_PATH=$HOME/local/app/libevent/include:$C_INCLUDE_PATH
# g++头文件
export CPLUS_INCLUDE_PATH=$HOME/local/app/libevent/include:$CPLUS_INCLUDE_PATH
注意:等号前面不要有空格。本例中,~/local/app/libevent/lib中包含了动态和静态链接库,不确定编译器类型,故加入到gcc和g++头文件搜索目录中。