Libpng warning: Incompatible version of libpng in application and library

I have an application that depends on many libraries (not all of us). Most of these libraries are installed through the package manager. For those that are not, I recompiled 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 

This is an error because the received buffer is empty. How do I know which library is associated with the new and which library is associated with the old?

 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 them are 1.2.44.

I am running Ubuntu 11.04 x86-64.

UPDATE. It turns out that OpenCV comes with its own version of libpng, which is 1.4.3.

+7
source share
3 answers

It looks like your application is dynamically linking the .so library file installed somewhere other than the header you are using. You can ldd <binary> find out which .so your binary is collecting, and then grab the header file from this directory (except the system directory) instead of the one you are using. This can be done by changing the -I flag at compile time. Otherwise, I think you need to install libpng-1.4.3 so that you can compile its headers.

+4
source

Mark B has explained this already. now aggain for matteo

your linker picks up the first appearance of libpng. which seems to be embedded in OpenCV. Look in your Makefile and put the local version before including OpenCV in Includes. In my case:

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

+1
source

As stated in your question, OpenCV comes with its own version of libpng, but you can use the version of libpng installed on your system instead. You can only do this when creating OpenCV from the source: disable BUILD_PNG when cmake starts.

0
source

All Articles