Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 
share|improve this question

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
    
perfect, thanks! –  user27422 Mar 10 '10 at 2:57

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.