RMagick をビルドする

ライブラリのインストールが終わったら、ImageMagick のビルドです。

ImageMagick

ImageMagick 6.4.9 を使います。別エントリに書きますが 6.5.x はダメです。(6.3.5以降はお好みで)

MinGW でのコンパイルについては Install-unix.txt に記されています。
現在のバージョンでは、スタティックビルドだけがサポートされているということです。

$ ./configure --without-perl --without-magick-plus-plus --with-quantum-depth=8 --disable-shared --with-modules --prefix=/c/MinGW
$ make
$ make check
()
validation suite: 2035 tests; 1775 passed; 260 failed.
FAIL: tests/validate.sh
()
$ make install

make check でひっかかるのは AI, EPDF, EPI, EPS, EPSF, EPSI, EPT, MOV, PDF, PDFA, PS 関係。
(tiff-3.9.0 はインストールして有効にしても動かなかった)

RMagick

まず /c/MinGW/bin (Magick-configと同じディレクトリ)に、Magick-config.bat を作成します。

Magick-config.bat の内容は、以下のとおり。

@echo off
sh Magick-config %*


また、extconf.rb が動かないので、一部修正します。

以下のパッチを ext/RMagick/extconf.patch として保存します。

*** extconf.rb.orig	Fri Aug 28 16:35:57 2009
--- extconf.rb	Wed Sep  2 15:43:28 2009
***************
*** 139,148 ****
    end
  
    # Save flags
!   $CFLAGS     = ENV["CFLAGS"].to_s   + " " + `Magick-config --cflags`.chomp
!   $CPPFLAGS   = ENV["CPPFLAGS"].to_s + " " + `Magick-config --cppflags`.chomp
!   $LDFLAGS    = ENV["LDFLAGS"].to_s  + " " + `Magick-config --ldflags`.chomp
!   $LOCAL_LIBS = ENV["LIBS"].to_s     + " " + `Magick-config --libs`.chomp
  
  else  # mswin
  
--- 139,148 ----
    end
  
    # Save flags
!   $CFLAGS     = $CFLAGS + " " + ENV["CFLAGS"].to_s   + " " + `Magick-config --cflags`.chomp
!   $CPPFLAGS   = $CPPFLAGS + " " + ENV["CPPFLAGS"].to_s + " " + `Magick-config --cppflags`.chomp
!   $LDFLAGS    = $LDFLAGS + " " + ENV["LDFLAGS"].to_s  + " " + `Magick-config --ldflags`.chomp
!   $LOCAL_LIBS = $LOCAL_LIBS + " " + ENV["LIBS"].to_s     + " " + `Magick-config --libs`.chomp
  
  else  # mswin
  
***************
*** 175,181 ****
  
  if RUBY_PLATFORM !~ /mswin/
  
!   unless have_library("MagickCore", "InitializeMagick", headers) || have_library("Magick", "InitializeMagick", headers)
      exit_failure "Can't install RMagick #{RMAGICK_VERS}. " +
             "Can't find the ImageMagick library or one of the dependent libraries. " +
             "Check the mkmf.log file for more detailed information.\n"
--- 175,181 ----
  
  if RUBY_PLATFORM !~ /mswin/
  
!   unless have_library("MagickCore") || have_library("Magick")
      exit_failure "Can't install RMagick #{RMAGICK_VERS}. " +
             "Can't find the ImageMagick library or one of the dependent libraries. " +
             "Check the mkmf.log file for more detailed information.\n"

パッチを当てるには

$ patch < extconf.patch

これで準備完了です。

$ ruby setup.rb all -- --with-opt-include=/mingw/include/ImageMagick --with-opt-dir=/mingw
$ ruby setup.rb install

install プロセスで、ドキュメント用の画像を作るスクリプトがテスト代わりということになります。
drawcomp.rb と stegano.rb でwmf2eps がらみのエラーが出ますが、それ以外は問題ないはず。
(これから使って問題でなけりゃね!)