libpng warning: Incompatible libpng version in application and library

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.


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