Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libpng warning: Incompatible libpng version in application and library

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

like image 387
Dat Chu Avatar asked Apr 04 '11 21:04

Dat Chu


2 Answers

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.

like image 200
Mark B Avatar answered Nov 02 '22 19:11

Mark B


Mark B explained it already. now aggain for Matteo

your linker picks up the first appearance of libpng. which seems to be nested in OpenCV. Have a look in your Makefile and put your local version before the include of OpenCV in the Includes. In my case:

-I/usr/include/libpng12 -lpng12 [ ... ] -L/usr/local/lib -lopencv_core

like image 35
user2412664 Avatar answered Nov 02 '22 19:11

user2412664