早速rmagickをインストールして見たらインストールに失敗してエラーがたくさん。
萎えるわー。萎えるわぁぁぁぁー。
そんな泣き言を言っているわけにもいかないので先人様達のお知恵をお借りして、直していきます。
前回の記事で、rubyを使って画像処理をやるのに自分が参考にしているサイトを記事にしてようやく検証しだした続きです。
おなじみのエラー発生
ちなみに環境はUbuntuです。毎度のごとくgemで突っ込もうと以下のコマンドを投入。
$ sudo gem install rmagick
そしたら以下のエラー発生。
$ sudo gem install rmagick Fetching: rmagick-2.15.0.gem (100%) Building native extensions. This could take a while... ERROR: Error installing rmagick: ERROR: Failed to build gem native extension. /usr/bin/ruby1.9.1 extconf.rb checking for gcc... yes checking for Magick-config... no checking for pkg-config... yes checking for outdated ImageMagick version (<= 6.4.9)... *** 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. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/usr/bin/ruby1.9.1 extconf.rb:79:in ``': No such file or directory - convert -version (Errno::ENOENT) from extconf.rb:79:in `block in configure_compile_options' from /usr/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for' from /usr/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone' from /usr/lib/ruby/1.9.1/mkmf.rb:254:in `open' from /usr/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone' from /usr/lib/ruby/1.9.1/mkmf.rb:254:in `open' from /usr/lib/ruby/1.9.1/mkmf.rb:280:in `postpone' from /usr/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for' from extconf.rb:76:in `configure_compile_options' from extconf.rb:15:in `initialize' from extconf.rb:474:in `new' from extconf.rb:474:in `<main>' Gem files will remain installed in /var/lib/gems/1.9.1/gems/rmagick-2.15.0 for inspection. Results logged to /var/lib/gems/1.9.1/gems/rmagick-2.15.0/ext/RMagick/gem_make.out
・・・・・・あれ?もしかしてサーバ自体にimagemagick入れてなかった?と思って調べてみたら入れてませんでした。別のサーバだったんだな〜。
ってことでまずはimagemagickをインストール。
$ sudo apt-get install imagemagick
よし!今度こそは!!ということで再度コマンド実行!!
$ sudo gem install rmagick Building native extensions. This could take a while... ERROR: Error installing rmagick: ERROR: Failed to build gem native extension. /usr/bin/ruby1.9.1 extconf.rb checking for gcc... yes checking for Magick-config... no checking for pkg-config... yes checking for outdated ImageMagick version (<= 6.4.9)... no Package MagickCore was not found in the pkg-config search path. Perhaps you should add the directory containing `MagickCore.pc' to the PKG_CONFIG_PATH environment variable No package 'MagickCore' found Package MagickCore was not found in the pkg-config search path. Perhaps you should add the directory containing `MagickCore.pc' to the PKG_CONFIG_PATH environment variable No package 'MagickCore' found Package MagickCore was not found in the pkg-config search path. Perhaps you should add the directory containing `MagickCore.pc' to the PKG_CONFIG_PATH environment variable No package 'MagickCore' found Package MagickCore was not found in the pkg-config search path. Perhaps you should add the directory containing `MagickCore.pc' to the PKG_CONFIG_PATH environment variable No package 'MagickCore' found checking for Ruby version >= 1.8.5... yes Package MagickCore was not found in the pkg-config search path. Perhaps you should add the directory containing `MagickCore.pc' to the PKG_CONFIG_PATH environment variable No package 'MagickCore' found Can't install RMagick 2.15.0. Can't find the ImageMagick library or one of the dependent libraries. Check the mkmf.log file for more detailed information. *** 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. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/usr/bin/ruby1.9.1 Gem files will remain installed in /var/lib/gems/1.9.1/gems/rmagick-2.15.0 for inspection. Results logged to /var/lib/gems/1.9.1/gems/rmagick-2.15.0/ext/RMagick/gem_make.out
むむむ・・・・またエラー発生。Makefileが作れないということで開発用のライブラリが入っていない様子。
ってことで再度apt-getで開発用ライブラリなどをインストール。
$ sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev
よし。今度こそ。
$ sudo gem install rmagick Building native extensions. This could take a while... Successfully installed rmagick-2.15.0 1 gem installed Installing ri documentation for rmagick-2.15.0... Installing RDoc documentation for rmagick-2.15.0...
はいったーーーーーーーーーーーーーーー!!
これでようやく環境が整った。
まとめ
ライブラリ関係のインストールが足りなかったんですね。
ってことでエラー内容から、Makefileが作れないとか出てきたら「libmagickcore-dev」と「libmagickwand-dev」を入れてあげましょう。
ようやく試せる・・・・時間かかってるなぁ。