9

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 (i.e. -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?)

brian
  • 157
  • 2
  • 10

1 Answers1

8

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.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055