libpng 警告:应用程序和库中的 libpng 版本不兼容
我有一个应用程序依赖于大量的库(我们不是都这样)。大多数这些库都是通过包管理器安装的。对于那些不是的,我重新编译了它们,但我仍然得到相同的 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
这是一个错误,因为生成的缓冲区是空的。我如何知道哪个库正在链接到新库以及哪个库正在链接到旧库?
ldd <executable-name>
...
libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f5a0660f000)
...
运行 locate png.h
为我提供了几个系统级文件,
/usr/include/png.h
/usr/include/libpng12/png.h
所有这些文件都是 1.2.44。
我正在运行 Ubuntu 11.04 x86-64。
更新:结果 OpenCV 附带了他们自己的 libpng 版本,即 1.4.3
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
看起来您的应用程序正在动态链接安装在您正在使用的标头之外的其他位置的找出您的二进制文件正在获取哪个
.so
库文件。您可以 ldd.so
,然后从该目录中获取头文件(除非它是系统目录)您正在使用的那个。您可以通过在编译时更改-I
标志来完成此操作。否则,我认为您需要安装libpng-1.4.3
以便可以根据其标头进行编译。It looks like your application is dynamically linking a
.so
library file installed somewhere other than the header you're using. You canldd <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 installlibpng-1.4.3
so you can compile against its headers.马克 B 已经解释过了。
现在,对于 Matteo,
您的链接器再次拾取 libpng 的第一次出现。这似乎是嵌套的
在 OpenCV 中。查看您的 Makefile 并将您的本地版本放在之前
OpenCV 包含在 Includes 中。就我而言:
-I/usr/include/libpng12 -lpng12 [ ... ] -L/usr/local/lib -lopencv_core
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
正如您的问题中所指出的,OpenCV 确实附带了自己的 libpng 版本,但您可以选择使用系统上安装的 libpng 版本。您只能在从源代码构建 OpenCV 时执行此操作:运行 cmake 时禁用 BUILD_PNG。
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/CMakeLists.txt 文件:
方法:再次编译 opencv,并使用此参数:
reason: OpenCV/CMakeLists.txt file:
ways:compile your opencv again, and use this param: