简体   繁体   English

自制软件+ opencv + libpng出错

[英]Error with homebrew + opencv + libpng

On Mac OS Maverick I have installed OpenCV with a brew install opencv . 在Mac OS Maverick上我已经安装了OpenCV和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

I checked that libpng was properly installed via brew install libpng and ran a brew upgrade to make sure everything was up-to-date. 我检查了libpng是否通过brew install libpng正确安装并运行brew upgrade以确保所有内容都是最新的。

Running locate libpng16.dylib returns: 运行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

Any idea? 任何想法?

The best solution is to fully uninstall libpng and re-install it: 最好的解决方案是完全卸载libpng并重新安装它:

$ sudo brew uninstall libpng
$ sudo rm '/usr/local/bin/libpng-config'
$ for i in `brew link --overwrite --dry-run libpng`; do sudo rm $i; done
$ sudo brew install libpng

If you need to install opencv: 如果你需要安装opencv:

$ sudo brew tap homebrew/science
$ sudo brew install opencv

Homebrew should ensure that you the correct dependencies install. Homebrew应该确保您安装正确的依赖项。 However, it's possible that you have more than one version of libpng16 installed at different paths. 但是,您可能在不同的路径上安装了多个版本的libpng16 Have a look in... 看看...

/usr/lib
/opt/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. 作为快速修复,您可以尝试在命令行上的程序名称之前键入DYLD_LIBRARY_PATH=/usr/local/lib In the longer term you may need to remove the conflicting versions altogether. 从长远来看,您可能需要完全删除冲突的版本。

This answer is for OSX users who installed through Conda, more specifically the conda-forge channel (I'm not sure about others). 这个答案适用于通过Conda安装的OSX用户,更具体地说是conda-forge通道(我不确定其他人)。

Conda ends up installing its own libpng in the environment and you can update it with conda upgrade libpng . Conda最终在环境中安装自己的libpng,你可以使用conda upgrade libpng进行更新。

I guess this is basically a bug with the opencv recipe on conda-forge. 我想这基本上是conda-forge上的opencv配方的一个错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM