libpng warning: Incompatible libpng version in application and library

Dat Chu picture Dat Chu · Apr 4, 2011 · Viewed 11.7k times · Source

I have an application which depends on a plethora of libraries (don't we all). Most of these libraries are installed via the package manager. For the ones which are not, I have re-compiled them but I still get the same libpng incompatibility error.

libpng warning: Application was compiled with png.h from libpng-1.2.44
libpng warning: Application  is  running with png.c from libpng-1.4.3

It is an error because the resulting buffer is empty. How do I know which library is linking to the new one and which library is linking to the old one?

ldd <executable-name>

...
libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f5a0660f000)
...

Running locate png.h gives me a couple of system-level files

/usr/include/png.h
/usr/include/libpng12/png.h

All of which are 1.2.44.

I am running Ubuntu 11.04 x86-64.

UPDATE: Turns out OpenCV ships with their own version of libpng which is 1.4.3

Answer

Mark B picture Mark B · Apr 4, 2011

It looks like your application is dynamically linking a .so library file installed somewhere other than the header you're using. You can ldd <binary> to figure out which .so your binary is picking up, and then grab the header file from that directory (unless it's a system directory) instead of the one you're using. You'd do this by changing your -I flag at compile time. Otherwise I think you'll need to install libpng-1.4.3 so you can compile against its headers.