无法打开共享对象文件,但库文件就在那里

时间:2013-12-24 13:38:10

标签: shared-libraries

我正在使用名为“md”的程序,它需要一个名为“beagle”的库。我将库安装到/ usr / local / lib:

$ ls /usr/local/lib/libhmsbeagle*
/usr/local/lib/libhmsbeagle-cpu.la         /usr/local/lib/libhmsbeagle-cpu-sse.so         /usr/local/lib/libhmsbeagle.la
/usr/local/lib/libhmsbeagle-cpu.so         /usr/local/lib/libhmsbeagle-cpu-sse.so.21      /usr/local/lib/libhmsbeagle.so
/usr/local/lib/libhmsbeagle-cpu.so.21      /usr/local/lib/libhmsbeagle-cpu-sse.so.21.0.0  /usr/local/lib/libhmsbeagle.so.1
/usr/local/lib/libhmsbeagle-cpu.so.21.0.0  /usr/local/lib/libhmsbeagle-jni.la             /usr/local/lib/libhmsbeagle.so.1.1.1
/usr/local/lib/libhmsbeagle-cpu-sse.la     /usr/local/lib/libhmsbeagle-jni.so

然后我运行程序,它哭了:

./mb: error while loading shared libraries: libhmsbeagle.so.1: cannot open shared object file: No such file or directory

我想它可能无法在/ usr / local / lib中找到东西,所以我将所有内容链接到/ usr / local / lib64,但是程序也出现了同样的错误。

最后,我将该文件链接到当前目录:

$ ln -s /usr/local/lib/libhmsbeagle.so.1 ./
$ ll libhmsbeagle.so.1
lrwxrwxrwx. 1 yx yx 32 Dec 24 20:50 libhmsbeagle.so.1 -> /usr/local/lib/libhmsbeagle.so.1

程序仍有相同的错误。

我确定程序和库都是ELF64:

$ readelf -h mb
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x402164
  Start of program headers:          64 (bytes into file)
  Start of section headers:          1724208 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         9
  Size of section headers:           64 (bytes)
  Number of section headers:         37
  Section header string table index: 34
$ readelf -h libhmsbeagle.so.1 
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x39e0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          41864 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         7
  Size of section headers:           64 (bytes)
  Number of section headers:         30
  Section header string table index: 27

那么,为什么?!!

1 个答案:

答案 0 :(得分:2)

通过在root上运行ldconfig解决。我之前从未使用过ldconfig。为什么有时我需要在安装新的.so文件后运行它,但大部分时间都没有?