1

I've got a problem linking to shared libraries. Specifically this is a nodejs module linking to libmemcached, but I'm guessing the problem is more generic than that. The file it cannot find/open is present, and everything is operating under /usr/local. Running as root doesn't let it see the file either.

I'm running CentOS 5.4

[node-memcache]$ node tests/test.js
Error: libmemcached.so.4: cannot open shared object file: No such file
or directory
[...]

[node-memcache]$ sudo find /usr -name "libmemcached.so.4"
/usr/local/lib/libmemcached.so.4 
user27422
  • 135
  • 1
  • 7

2 Answers2

3

TLDP has a pretty good write up about shared libraries, discussing both how to create them and how to use them.

Your problem, however, is likely because your execution environment does not know where to find libmemcached. The search path is stored in the LD_LIBRARY_PATH environment variable. Try running this command before executing node:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

If that works, then add that to your profile so the variable will be set every time you start a new shell session.

Scott Pack
  • 14,717
  • 10
  • 51
  • 83
2

If you keep some of the libraries in /usr/local/lib directory, then you should add it to the /etc/ld.so.conf file and run the ldconfig command. Maybe, running ldconfig is the only thing you need (if ld.so.conf is already right).

Using the LD_LIBRARY_PATH environment variable will also work, but is less efficient, as ldconfig cache is not used in this case.

Jacek Konieczny
  • 3,597
  • 2
  • 21
  • 22