我正在使用ruby-opencv
gem在ruby上使用opencv。我使用Homebrew来安装opencv。 opencv和ruby的安装成功,但是当我尝试运行任何示例时,我收到以下错误 -
/usr/local/Cellar/ruby/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': dlopen(/usr/local/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0/ruby-opencv-0.0.14/opencv.bundle, 9): Library not loaded: /usr/local/lib/libpng16.16.dylib (LoadError)
Referenced from: /usr/local/lib/libopencv_highgui.2.4.dylib
Reason: Incompatible library version: libopencv_highgui.2.4.dylib requires version 34.0.0 or later, but libpng16.16.dylib provides version 33.0.0 - /usr/local/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0/ruby-opencv-0.0.14/opencv.bundle
from /usr/local/Cellar/ruby/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/lib/ruby/gems/2.2.0/gems/ruby-opencv-0.0.14/lib/opencv.rb:11:in `<top (required)>'
from /usr/local/Cellar/ruby/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
from /usr/local/Cellar/ruby/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from /usr/local/Cellar/ruby/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from opencv.rb:1:in `<main>'
我该怎么做才能解决这个问题?
答案 0 :(得分:1)
正如您在错误消息中看到的那样(此处:requires version 34.0.0 or later, but libpng16.16.dylib provides version 33.0.0
)OpenCV需要34.00或更高版本的libpng(并且您有33.0.0),因此您需要安装此lib的较新版本。如果简单的brew install libpng
无法解决问题,请尝试卸载它,然后再使用this solution重新安装。