2012/07/01

[RubyonRails3]rmagickのインストール for windows7




rmagickのインストールでハマりました。

利用するにはimagemagickのインストールも必要
http://www.imagemagick.org/script/binary-releases.php#windows

ここで「ImageMagick-6.7.8-0-Q16-windows-dll.exe」をダウンロードしてインストール。(僕のPCは64bit)


インストールでは基本デフォルトのままでよいがSelectAdditionalTask画面(チェックボックスが6個ある画面)では下記3つを選択。
・Create a desktop icon
・Add application directory to your system path
・Install development headers and libraries for C and C++






インストール後は一度PCを再起動してコマンドプロンプトでconvert --versionで下記メッセージを確認※うまく動作しない場合は環境変数にインストール先のパスが指定されているかチェック。

Version: ImageMagick 6.7.8-0 2012-06-28 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

その後、
gem install rmagick
を行うと下記エラーが出てきた。

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.

        C:/Ruby192/bin/ruby.exe extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... *** 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=C:/Ruby192/bin/ruby
C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp'
        from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:834:in `block in have_header'
        from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
        from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'
        from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
        from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
        from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
        from C:/Ruby192/lib/ruby/1.9.1/mkmf.rb:833:in `have_header'
        from extconf.rb:193:in `<main>'


Gem files will remain installed in C:/Ruby192/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1 for inspection.
Results logged to C:/Ruby192/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1/ext/RMagick/gem_make.out


オプションを利用してimagemagickのパスを指定することでエラーが出なくなった。
gem install rmagick -v '2.13.1' -- '--platform=ruby --with-opt-lib="C:\Program Files (x86)\ImageMagick-6.7.8-Q16\lib" --with-opt-include="C:\Program Files (x86)\ImageMagick-6.7.8-Q16\include"'

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed rmagick-2.13.1
1 gem installed
Installing ri documentation for rmagick-2.13.1...
Installing RDoc documentation for rmagick-2.13.1...

ちなみに僕の環境のバージョン
>ruby --version
ruby 1.9.2p290 (2011-07-09) [i386-mingw32]

>rails --version
Rails 3.1.3


0 件のコメント:

コメントを投稿