※ 追記あり
gem で nokogiri をインストールしようとしたところ、次のようなエラーが出てインストールできなかった。
^o^ > gem install nokogiri
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
C:/Ruby200-x64/bin/ruby.exe extconf.rb
checking for libxml/parser.h... no
-----
libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokog
iri.html for help with installing dependencies.
-----
*** 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:/Ruby200-x64/bin/ruby
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-libxslt-config
--without-libxslt-config
--with-pkg-config
--without-pkg-config
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--with-libiconv-config
--without-libiconv-config
--with-pkg-config
--without-pkg-config
Gem files will remain installed in C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nokog
iri-1.6.1 for inspection.
Results logged to C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/nokogiri-1.6.1/ext/nok
ogiri/gem_make.out
調べてみると、どうやら nokogiri はもはや Pure Ruby ではなく、おまけにほかのCライブラリに依存するらしい。
Windows の Ruby 2.0.0 に nokogiri をインストールする方法はこのページに詳しい。
cf. WindowsのRuby 2.0でNokogiriを使う ― KaoriYa
というわけで、ここからが今日の本題。C のライブラリをビルドするためにまずは MinGW のインストールに挑戦する。
まずは、ダウンロードページから mingw-get-setup.exe をダウンロード。これを右クリックして管理者として実行する。
順調に進むかと思いきや、「”C:\MinGW\libexec\mingw-get\shlink.js” のスクリプト エンジン “JScript” が見つかりません。」というエラーがでてしまう。先週、有効にしたはずなのにおかしい。
とりあえず「OK」をクリックすると MinGW Installation Manager というパッケージ管理ツールのウィンドウが開く。ここでインストールしたいパッケージを選んで(よくわからんので Basic Setup にあるすべてを選んだ)、メニューから Installation → Apply Changes をクリックするとインストールが始まって、しばらくすると無事終わった(ように見える)。
ところが、スタートメニューにもデスクトップにもショートカットが作成されていない。これってやっぱり正常にインストールされてないってことか?
試しに簡単なプログラムを書いてみた。
#include
main () {
printf("Hello, world.\n")
}
実行結果:
^o^ > gcc -o hello.exe hello.c
^o^ > hello.exe
Hello, world.
なんと、コンパイルができてしまった。どういうこと?
[追記]
gcc が使えたのは、MinGW が正常にインストールされているわけじゃなかった。Haskell Platform に含まれてる gcc が動いていた。
^o^ > which gcc
C:/Program Files (x86)/Haskell Platform/2012.4.0.0/mingw/bin/gcc.EXE
MinGW のほうにパスを通せばいいのかなあ。shlink.js が何をやってるのか調べてみようか。