libpng warning: Incompatible libpng version in application and library
Asked Answered
U

4

11

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

Unweighed answered 4/4, 2011 at 21:15 Comment(1)
@Dat Chu - I'm facing your same problem, since you found out that OpenCV ships their own version of libpng what should I do to compile my code correctly?which of the 2 suggestions below did you follow? thanks for your help!Expatriate
O
5

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.

Ochone answered 4/4, 2011 at 21:20 Comment(0)
B
1

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

Bird answered 23/5, 2013 at 8:17 Comment(0)
B
0

As pointed out in your question, OpenCV does ship with its own version of libpng, but you can opt to use the version of libpng installed on your system instead. You can only do this when building OpenCV from source: disable BUILD_PNG when running cmake.

Bronchoscope answered 12/11, 2012 at 3:20 Comment(0)
S
0

reason: OpenCV/CMakeLists.txt file:

OCV_OPTION(BUILD_PNG   "Build libpng from source"   WIN32 OR ANDROID OR APPLE)

enter image description here

ways:compile your opencv again, and use this param:

cmake -D BUILD_PNG=ON (+your other params)
make
sudo make install
Stripper answered 14/3, 2019 at 6:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.