问题描述
在Mac OS Maverick上,我已经安装了带有brew install opencv
的OpenCV.
On Mac OS Maverick I have installed OpenCV with a brew install opencv
.
我创建了一个简单程序(从本教程).编译工作正常,但是在运行可执行文件时出现以下错误:
I created a simple program (copied from this tutorial). Compilation worked fine but when running the executable I get the following error:
dyld: Library not loaded: /usr/local/lib/libpng16.16.dylib
Referenced from: /usr/local/lib/libopencv_highgui.2.4.dylib
Reason: Incompatible library version: libopencv_highgui.2.4.dylib requires version 33.0.0 or later, but libpng16.16.dylib provides version 32.0.0
Trace/BPT trap: 5
我检查了libpng
是否已通过brew install libpng
正确安装,并运行了brew upgrade
以确保所有内容都是最新的.
I checked that libpng
was properly installed via brew install libpng
and ran a brew upgrade
to make sure everything was up-to-date.
正在运行locate libpng16.dylib
返回:
/Applications/GIMP.app/Contents/Resources/lib/libpng16.16.dylib
/usr/local/Cellar/libpng/1.6.10/lib/libpng16.16.dylib
/usr/local/Cellar/libpng/1.6.12/lib/libpng16.16.dylib
/usr/local/Cellar/libpng/1.6.13/lib/libpng16.16.dylib
/usr/local/Cellar/libpng/1.6.15/lib/libpng16.16.dylib
/usr/local/lib/libpng16.16.dylib
有什么主意吗?
推荐答案
Homebrew应该确保您安装了正确的依赖项.但是,有可能在不同的路径上安装了多个版本的libpng16
.看看...
Homebrew should ensure that you the correct dependencies install. However, it's possible that you have more than one version of libpng16
installed at different paths. Have a look in...
/usr/lib
/opt/local/lib
如果在这些位置找到该库的任何版本,则它们可能会导致在程序启动时加载错误的版本.作为快速解决方案,您可以尝试在命令行上在程序名称之前键入DYLD_LIBRARY_PATH=/usr/local/lib
.从长远来看,您可能需要完全删除有冲突的版本.
If you find any versions of the library in these locations then they may be causing the wrong one to be loaded when your program starts. As a quick fix you can try typing DYLD_LIBRARY_PATH=/usr/local/lib
before your program name on the command line. In the longer term you may need to remove the conflicting versions altogether.
这篇关于自制软件+ opencv + libpng错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!