error while loading shared libraries libpng16

Michal Krakovsky picture Michal Krakovsky · Aug 28, 2014 · Viewed 28.5k times · Source

I am trying to compile and run this code under ubuntu 14.04. I downloaded and installed libpng version 1.6.12. I am able to compile the code using gcc test.c -lpng but when I try to run it, I get this error: ./a.out: error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory

edit:
So I found libpng16.so.16, it was in /usr/local/lib and I copied it to /usr/local/include/libpng16/ and as well to /usr/local/include/ and recompiled the code, anyway the problem still persists.

Any suggestions ?

Answer

Michal Krakovsky picture Michal Krakovsky · Aug 29, 2014

Ok so I found the solution here. The trick is to run sudo ldconfig after you install some shared library.