Linux libpng 警告:应用程序和库中的 libpng 版本不兼容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5544445/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
libpng warning: Incompatible libpng version in application and library
提问by Dat Chu
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
更新:原来 OpenCV 附带了他们自己的 libpng 版本,即 1.4.3
采纳答案by Mark B
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 <binary>
找出其中.so
你的二进制捡了起来,然后抓住从该目录中的头文件(除非它是一个系统目录),而不是您使用的一个。您可以通过-I
在编译时更改标志来做到这一点。否则我认为您需要安装libpng-1.4.3
以便您可以针对其标头进行编译。
回答by mpenkov
As pointed out in your question, OpenCV doesship 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。
回答by user2412664
Mark B explained it already. now aggain for Matteo
Mark B 已经解释过了。现在又是马特奥
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 beforethe 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