百聞は一見に如かず~文字列処理+画像処理=? ─小飼弾からの挑戦 というのを見つけて、perl + GD でプログラムを作ってみた。
最初、リモートサーバーのcentos6.3上で作り始めて、 GD本体は最初から入ってて、 perlのGDライブラリはyumでさくっとインストールできたので、 順調にプログラムは完成したんだけど、 自分が普段メインで使っているローカルマシン(MacOS X 10.8)でも動かしてみようと思って、 ローカルにプログラムを持ってきて動かそうとしたら、GD.pmがない、と言われて動かなかった。 MacOS X 10.8 に GD.pm をインストールするのに苦労して、そして遠回りした。
GD自体は homebrew で brew install gd
で問題なくインストールが完了。
OS X 10.8 Mountain Lion にデフォルトでインストールされているperlは v5.12.4。
このperlに対して cpanm GD
でインストールしようとすると、
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
Testing using png support.
t/GD.t ........
Failed 1/12 subtests
(less 2 skipped subtests: 9 okay)
t/Polyline.t .. ok
Test Summary Report
-------------------
t/GD.t (Wstat: 0 Tests: 12 Failed: 1)
Failed test: 10
Files=2, Tests=13, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.16 cusr 0.02 csys = 0.21 CPU)
Result: FAIL
Failed 1/2 test programs. 1/13 subtests failed.
make: *** [test_dynamic] Error 255
-> FAIL Installing GD failed. See /Users/18hb/.cpanm/build.log for details.
というエラーが出てインストールができない。 その他にも、
LD_RUN_PATH="/usr/local/lib:/usr/local/Cellar/libpng/1.5.13/lib:/usr/lib:/usr/local/Cellar/gd/2.0.36RC1/lib" clang -mmacosx-version-min=10.8 -arch i386 -arch x86_64 -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector GD.o -o blib/arch/auto/GD/GD.bundle \
-L/usr/local/Cellar/libpng/1.5.13/lib -L/usr/local/Cellar/gd/2.0.36RC1/lib -ljpeg -lpng -lz -liconv -lgd \
ld: warning: ignoring file GD.o, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 1 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): GD.o
ld: warning: ignoring file /usr/local/lib/libpng.dylib, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): /usr/local/lib/libpng.dylib
ld: warning: ignoring file /usr/local/lib/libgd.dylib, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): /usr/local/lib/libgd.dylib
なんて警告も出てて、最初、リンクに失敗してる???とか、いろいろ試行錯誤して、 いろいろググったりして結構はまってた。
いろいろググって最後にたどり着いたのが、毎度おなじみStack Overflow。
なにやら、テストで失敗しているだけで強制インストールすることはできる、みたいなことが書いてあったので、
cpanm --force GD
とやったら、インストールが完了した!
プログラムを動かしてみたら、きちんと動作していたのでGDの動きも問題なさそうだった。 強制インストールにたどり着くまで2時間くらい迷走してました。。