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

发布于 2024-10-30 08:13:17 字数 685 浏览 2 评论 0原文

我有一个应用程序依赖于大量的库(我们不是都这样)。大多数这些库都是通过包管理器安装的。对于那些不是的,我重新编译了它们,但我仍然得到相同的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

摇划花蜜的午后 2024-11-06 08:13:17

看起来您的应用程序正在动态链接安装在您正在使用的标头之外的其他位置的 .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 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.

对你而言 2024-11-06 08:13:17

马克 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

初见你 2024-11-06 08:13:17

正如您的问题中所指出的,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.

红颜悴 2024-11-06 08:13:17

原因:OpenCV/CMakeLists.txt 文件:

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

在此处输入图像描述

方法:再次编译 opencv,并使用此参数:

cmake -D BUILD_PNG=ON (+your other params)
make
sudo make install

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文