C++ – Error while loading shared libraries

c

I am a C++ beginner. I have a c++ project that i built using the existing make files. I have a library that I linked from /usr/local/lib. Build is successful but when I run it, its complaining about the library that I linked form /usr/local/lib. If I copy that library to /lib64 and run my program, everything is fine. Please let me know what I should do to avoid this error. Thank you.

error while loading shared libraries: libactivemq-cpp.so.14: cannot
open shared object file: No such file or directory

Best Answer

As Oli explained, you can set LD_LIBRARY_PATH, but you can also install the library permanently, even if it doesn't live in one of the standard directories. Start with

man ldconfig

it's quite important you know how that thing works.

  • by default (ie unless you do something) only libraries in the trusted directories (/lib and /usr/lib) will be picked up. I have no running 64 bits system available but i'm guessing on those the directories will be suffixed with 64
  • if you want ldconfig to pick up libraries in other dirs, add theses directories to /etc/ld.so.conf
  • after that, run ldconfig -v and check if they actually got picked up

And you'll be all set :-)