libpng警告:应用程序和库中的libpng版本不兼容

时间:2021-10-13 07:00:09

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不兼容错误。

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

运行locate png.h给了我几个系统级文件

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

All of which are 1.2.44.

所有这些都是1.2.44。

I am running Ubuntu 11.04 x86-64.

我正在运行Ubuntu 11.04 x86-64。

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

更新:使用他们自己的libpng版本1.4.3打开OpenCV

3 个解决方案

#1


4  

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.

看起来您的应用程序正在动态链接安装在您正在使用的标头之外的某个.so库文件。您可以ldd 找出你的二进制文件正在拾取的.so然后从该目录中获取头文件(除非它是系统目录)而不是你正在使用的那个。你可以通过在编译时更改-I标志来完成此操作。否则我认为你需要安装libpng-1.4.3,这样你就可以针对它的头进行编译。

#2


1  

Mark B explained it already. now aggain for Matteo

马克B已经解释过了。现在为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:

你的链接器选择了libpng的第一个外观。它似乎嵌套在OpenCV中。查看Makefile并在包含OpenCV之前添加本地版本。就我而言:

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

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

#3


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.

正如您的问题所指出的,OpenCV确实附带了自己的libpng版本,但您可以选择使用系统上安装的libpng版本。您只能在从源代码构建OpenCV时执行此操作:在运行cmake时禁用BUILD_PNG。

#1


4  

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.

看起来您的应用程序正在动态链接安装在您正在使用的标头之外的某个.so库文件。您可以ldd 找出你的二进制文件正在拾取的.so然后从该目录中获取头文件(除非它是系统目录)而不是你正在使用的那个。你可以通过在编译时更改-I标志来完成此操作。否则我认为你需要安装libpng-1.4.3,这样你就可以针对它的头进行编译。

#2


1  

Mark B explained it already. now aggain for Matteo

马克B已经解释过了。现在为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:

你的链接器选择了libpng的第一个外观。它似乎嵌套在OpenCV中。查看Makefile并在包含OpenCV之前添加本地版本。就我而言:

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

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

#3


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.

正如您的问题所指出的,OpenCV确实附带了自己的libpng版本,但您可以选择使用系统上安装的libpng版本。您只能在从源代码构建OpenCV时执行此操作:在运行cmake时禁用BUILD_PNG。