highgui 抱怨当我有 20.0 时它需要 >=17.0.0
这是一种丑陋的,但我被困住了,所以它是这样的:
我正在编写一个动态库(此后称为“mylib.dylib”),它使用 opencv(highgui 和其他部分)并最终由 ffmpeg(libavfilter)加载。该库编译得很好。但是当我尝试从 ffmpeg 中 dlopen() dylib 时,出现以下错误:
mylib.dylib: dlopen(mylib.dylib, 2): Library not loaded: /usr/local/lib/libpng15.15.dylib
Referenced from: /usr/local/lib/libopencv_highgui.2.3.dylib
Reason: Incompatible library version: libopencv_highgui.2.3.dylib requires version 17.0.0 or later, but libpng15.15.dylib provides version 16.0.0
但是,当我运行 otool -L /usr/local/lib/libpng15.15.dylib 时,我得到以下:
/usr/local/lib/libpng15.15.dylib:
/usr/local/lib/libpng15.15.dylib (compatibility version 20.0.0, current version 20.0.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.0.0)
我上次检查时,20.0.0 晚于 17.0.0,这是 highgui 所说的要求。
我想这可能是一个架构问题(我在运行 Lion 的 Mac 上,所以我在 i386/x86_64 上遇到了很多问题),但是在所有库上运行“file”显示所有内容(highgui、libpng、 mylib) 是 Mach-O 64 位动态链接共享库 x86_64
我想也许我的系统上某个地方隐藏着一些其他版本的 libpng,但 dlopen 错误特别指出/usr/local/lib/libpng15.15.dylib
显然我在这里缺少一些东西——不可否认,我不是这些动态库如何链接的专家。因此,如果我忘记包含一些相关信息,请原谅。
更新 我忘了提及——当我通过 XCode 运行 ffmpeg 时,该库工作正常(没有 dlopen 错误),这让我相信它可能与 XCode 设置的环境变量有关,而我没有设置。
谢谢!
解决方案 1.别犯傻 我正在使用 MAMP,因为我通过 php 脚本调用 ffmpeg,所以它使用自己的一组 dylib,其中(令人惊讶)包括 libpng 16.0.0
This is kind of an ugly one, but I am stuck so here it goes:
I am writing a dynamic library (henceforth 'mylib.dylib') that uses opencv (highgui and other parts) and is ultimately loaded by ffmpeg (libavfilter). The library compiles just fine. But when I try to dlopen() the dylib from within ffmpeg, I get the following error:
mylib.dylib: dlopen(mylib.dylib, 2): Library not loaded: /usr/local/lib/libpng15.15.dylib
Referenced from: /usr/local/lib/libopencv_highgui.2.3.dylib
Reason: Incompatible library version: libopencv_highgui.2.3.dylib requires version 17.0.0 or later, but libpng15.15.dylib provides version 16.0.0
However, when I run otool -L /usr/local/lib/libpng15.15.dylib I get the following:
/usr/local/lib/libpng15.15.dylib:
/usr/local/lib/libpng15.15.dylib (compatibility version 20.0.0, current version 20.0.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.0.0)
Last time I checked, 20.0.0 is later than 17.0.0, which is what highgui said it requires.
I thought maybe it was an architecture problem (I am on a Mac running Lion, so I've encountered a lot of problems with i386/x86_64), but running 'file' on all of the libraries revealed that everything (highgui, libpng, mylib) is Mach-O 64-bit dynamically linked shared library x86_64
I thought perhaps there was some other version of libpng hiding on my system somewhere, but the dlopen error specifically points to /usr/local/lib/libpng15.15.dylib
There is obviously something that I am missing here -- admittedly I am no expert on how these dynamic libraries link. So if I forgot to include some pertinent info, please excuse me.
UPDATE
I forgot to mention -- the lib works fine when I run ffmpeg through XCode (no dlopen error) which leads me to believe that it might have something to do with a environment variable that XCode is setting that I am not.
Thanks!
SOLUTION
1. Don't be dumb
I was using MAMP and since I was calling ffmpeg through a php script, it was using its own set of dylibs, which (surprise surprise) included libpng 16.0.0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最近,在卸载所有 MacPort 并安装更新版本后,我遇到了类似的情况。问题在于 libpng 的版本(1.2 vs 1.4 vs 1.5),而不仅仅是兼容性版本。我已经针对 libpng 1.4(即 libpng14)构建了 OpenCV。我以为我可以使用 install_name_tool 来让它查看 libpng 1.5 (libpng15),但这不起作用。我最终根据当前版本的库重建了 OpenCV。效果很好(在我记得 sudo cmake install 后)。
(上面的某些版本号可能不正确,但要点是准确的。)
因此,要么您没有构建 OpenCV 时最初拥有的 libpng 版本,要么它是针对 /usr/local/lib 中的 libpng 以外的 libpng 构建的(可能就像 /opt/local/lib 中的那个)。如果是这种情况,您需要确保您正在根据您想要使用的版本进行构建。如何执行此操作取决于您的构建方法(MacPorts 或 cmake)。我对 OpenCV 使用 cmake,对其他库使用 MacPorts,这就是为什么两者在我的系统上不同步的原因。
I had something similar recently after I uninstalled all my MacPorts and installed updated versions. The problem was the version of libpng (1.2 vs 1.4 vs 1.5), not just the compatibility version. I had built OpenCV against libpng 1.4 (which is libpng14). I thought I could just use install_name_tool to make it look at libpng 1.5 (libpng15) instead but that didn't work. I ended up rebuilding OpenCV against the current versions of the library. That worked fine (after I remembered
sudo cmake install
).(Some version numbers above might be incorrect but the gist is accurate.)
So either you don't have the version of libpng you originally had when you built OpenCV or it built against a libpng other than the one in /usr/local/lib (like maybe the one in /opt/local/lib). If that's the case you'll need to make sure you're building against the version you want to use. How to do that depends on your build method (MacPorts or cmake). I use cmake for OpenCV and MacPorts for other libraries which is why the two got out of sync on my system.
仅供那些需要代码的人使用:
Just for those who need the code: