jiandingzhe
jiandingzhe

Reputation: 2121

cannot open shared object file, but the library file is just there

I'm using a program named "md", and it need a library named "beagle". I installed the library to /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

then I run the program, it cries:

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

I guess it might not finding things in /usr/local/lib, so I linked everything to /usr/local/lib64, but the program cried the same error.

Finally I linked that file to current directory:

$ 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

the program still have the same error.

I'm sure both the program and the library are 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

So, why?!!

Upvotes: 3

Views: 1512

Answers (1)

jiandingzhe
jiandingzhe

Reputation: 2121

Solved by running ldconfig on root. I never used ldconfig before. Why sometimes I need to run it after installed a new .so file, but most times not?

Upvotes: 2

Related Questions