Edited at

ruby-opencvがインストールできない

More than 1 year has passed since last update.


環境

High Sierra 10.10.3

HomeBrew 1.6.2

gem 2.4.5.1

OpenCV3


実行コマンド

gem install ruby-opencv


エラー

Building native extensions.  This could take a while...

ERROR: Error installing ruby-opencv:
ERROR: Failed to build gem native extension.

>> Check the required libraries...
checking for main() in -lstdc++... yes
checking for main() in -lopencv_calib3d... yes
checking for main() in -lopencv_contrib... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.


解決策

OpenCV3にはlopencv_contribがないのでOpenCV2をインストール

brew install opencv@2

gemをインストールする際にOpenCV2のパスを指定

gem install ruby-opencv -- --with-opencv-dir=/usr/local/opt/opencv@2