简体   繁体   中英

“cannot open shared object file,” but it exists

I'm having trouble finding why this library (matio) isn't working for me. In my Makefile I have this:

LIBS += -L/home/brian/.../matio-1.5.6/src/.libs/ -lmatio

When I attempt to run my code (links fine) I get this error:

error while loading shared libraries: libmatio.so.4: cannot open shared object file: No such file or directory

libmatio.so.4 exists in the directory specified by the -L flag.

I built the library and it seems to go through make check with only a handful writing errors (which is fine as I only need it for reading).

Things I've tried:

  • Specifying the name (ie -l:libmatio.so.4.0.2 )
  • Adding the path to LD_LIBRARY_PATH
  • Adding the path as a line in /etc/ld.so.conf and run sudo ldconfig
  • Adding a new file in /etc/ld.so.conf.d with the path and run sudo ldconfig

(When I run ldconfig -p | grep matio nothing returns. Am I doing something wrong with ldconfig ?)

The error is actually telling you "no compatible library with that name exists in the library cache", not "no file with that filename exists on disk".

So, confusingly, this can happen when the shared object file is in the wrong format.

Ensure that it was built for the right platform by the right compiler! You can have a look with file and verify that the dynamic link is failing using ldd on your executable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM