20

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 ?

Michal Krakovsky
  • 755
  • 3
  • 7
  • 16

3 Answers3

32

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

Community
  • 1
  • 1
Michal Krakovsky
  • 755
  • 3
  • 7
  • 16
11

You can download the library from the link https://sourceforge.net/projects/libpng/?source=directory

It will download a file something like "libpng-1.6.32.tar.xz"

Simply extract the file go inside folder and run these commands to install

./configure
make check
make install

Then you need to run after installing any library

ldconfig
Krishan Kumar Mourya
  • 1,878
  • 2
  • 21
  • 29
0

I had same problem before I had installed it form below link and problem fixed.

I hope yours would be fixed as well

PNG reference library: libpng

Mehdi Golzadeh
  • 2,141
  • 1
  • 11
  • 21