0
votes

I'm using a node module png which use libpng. After installing libpng, I find some libs in /usr/local/lib. I require the png module:

var png = require('png')

It complained that libpng16.so could not be found.

Error: libpng16.so.16: cannot open shared object file: No such file or directory

But libpng16.so.16 does exist in /usr/local/lib. Then I copy all libpng* to /usr/lib and run code above again, no error for this time!

My question: how could I let Node search libs in /usr/local/lib?

Thanks!

1
Can you try updating the cache file /etc/ld.so.cache? stackoverflow.com/questions/4743233/…nodakai

1 Answers

1
votes

This is a Linux "installing libraries" issue, not a node.js issue (I was confused by the same thing & landed here looking for ideas).

make install will typically copy the library to /usr/local/lib and output some boilerplate suggesting that you modify LD_LIBRARY_PATH or update the ld config. But it doesn't do this for you. (One thing that can make this more confusing is that the compiler toolchain will search /usr/local by default, so any dependent libraries will compile/link fine.)

Running ldconfig (/sbin/ldconfig) as root or with sudo will update the run-time linker cache, and fix the problem. If not, check that at least one of /etc/ld.so.conf or any of the files in /etc/ld.so.conf.d/ contains the line '/usr/local/lib'.

For more information, run man ldconfig