Gentoo Linuxにgollumを導入する

Portageでインストールしたruby-2.0なGentooLinuxにgollumをインストールします。

gollumに必要なcharlock_holmesというgemのインストールでエラーが出てしまいます。

$ gem install charlock_holmes
Building native extensions with: '--with-icu-dir=/usr/lib/icu'
This could take a while...
ERROR:  Error installing charlock_holmes:
        ERROR: Failed to build gem native extension.

    /usr/bin/ruby20 extconf.rb --with-icu-dir=/usr/lib/icu
checking for main() in -licui18n... yes
checking for main() in -licui18n... yes
checking for unicode/ucnv.h... yes
  -- tar zxvf file-5.08.tar.gz
  -- ./configure --prefix=/home/rkmathi/.gem/ruby/2.0.0/gems/charlock_holmes-0.6.9.4/ext/charlock_holmes/dst/ --disable-
shared --enable-static --with-pic
  -- patch -p0 < ../file-soft-check.patch
  -- make -C src install
  -- make -C magic install
checking for main() in -lmagic_ext... yes
checking for magic.h... yes
creating Makefile

make "DESTDIR="
compiling converter.c
In file included from converter.c:2:0:
common.h:23:14: warning: ‘charlock_new_str’ defined but not used [-Wunused-function]
common.h:32:14: warning: ‘charlock_new_str2’ defined but not used [-Wunused-function]
compiling ext.c
In file included from ext.c:1:0:
common.h:14:14: warning: ‘charlock_new_enc_str’ defined but not used [-Wunused-function]
common.h:23:14: warning: ‘charlock_new_str’ defined but not used [-Wunused-function]
common.h:32:14: warning: ‘charlock_new_str2’ defined but not used [-Wunused-function]
compiling encoding_detector.c
In file included from encoding_detector.c:3:0:
common.h:14:14: warning: ‘charlock_new_enc_str’ defined but not used [-Wunused-function]
compiling transliterator.cpp
linking shared-object charlock_holmes/charlock_holmes.so
converter.o: In function `rb_converter_convert':
converter.c:(.text+0xb4): undefined reference to `ucnv_convert'
converter.c:(.text+0xf4): undefined reference to `ucnv_convert'
converter.c:(.text+0x18e): undefined reference to `u_errorName'
encoding_detector.o: In function `rb_get_supported_encodings':
encoding_detector.c:(.text+0xa0): undefined reference to `uenum_count'
encoding_detector.c:(.text+0xc1): undefined reference to `uenum_next'
encoding_detector.c:(.text+0x12a): undefined reference to `uenum_next'
encoding_detector.c:(.text+0x16c): undefined reference to `uenum_next'
encoding_detector.c:(.text+0x1aa): undefined reference to `uenum_next'
encoding_detector.c:(.text+0x1f1): undefined reference to `uenum_next'
encoding_detector.o:encoding_detector.c:(.text+0x22e): more undefined references to `uenum_next' follow
encoding_detector.c:(.text+0x1f1): undefined reference to `uenum_next'                                          [59/930]
encoding_detector.o:encoding_detector.c:(.text+0x22e): more undefined references to `uenum_next' follow
encoding_detector.o: In function `rb_encdec__alloc':
encoding_detector.c:(.text+0x73d): undefined reference to `u_errorName'
transliterator.o: In function `rb_transliterator_id_list':
transliterator.cpp:(.text+0x158): undefined reference to `u_errorName'
transliterator.o: In function `rb_transliterator_transliterate':
transliterator.cpp:(.text+0x2dd): undefined reference to `icu::UnicodeString::UnicodeString(char const*, int)'
transliterator.cpp:(.text+0x305): undefined reference to `icu::UnicodeString::~UnicodeString()'
transliterator.cpp:(.text+0x31b): undefined reference to `icu::UMemory::operator new(unsigned long)'
transliterator.cpp:(.text+0x331): undefined reference to `icu::UnicodeString::UnicodeString(char const*, int)'
transliterator.cpp:(.text+0x36a): undefined reference to `icu::UnicodeString::toUTF8(icu::ByteSink&) const'
transliterator.cpp:(.text+0x3b5): undefined reference to `icu::ByteSink::~ByteSink()'
transliterator.cpp:(.text+0x405): undefined reference to `u_errorName'
transliterator.cpp:(.text+0x46f): undefined reference to `icu::UMemory::operator delete(void*)'
transliterator.cpp:(.text+0x4a0): undefined reference to `icu::UnicodeString::~UnicodeString()'
transliterator.o: In function `icu::StringByteSink<std::string>::~StringByteSink()':
transliterator.cpp:(.text._ZN3icu14StringByteSinkISsED2Ev[_ZN3icu14StringByteSinkISsED5Ev]+0xf): undefined reference to
`icu::ByteSink::~ByteSink()'
transliterator.o: In function `icu::StringByteSink<std::string>::~StringByteSink()':
transliterator.cpp:(.text._ZN3icu14StringByteSinkISsED0Ev[_ZN3icu14StringByteSinkISsED0Ev]+0x13): undefined reference to
 `icu::ByteSink::~ByteSink()'
transliterator.cpp:(.text._ZN3icu14StringByteSinkISsED0Ev[_ZN3icu14StringByteSinkISsED0Ev]+0x1c): undefined reference to
 `icu::UMemory::operator delete(void*)'
transliterator.o:(.data.rel.ro._ZTVN3icu14StringByteSinkISsEE[_ZTVN3icu14StringByteSinkISsEE]+0x28): undefined reference
 to `icu::ByteSink::GetAppendBuffer(int, int, char*, int, int*)'
transliterator.o:(.data.rel.ro._ZTVN3icu14StringByteSinkISsEE[_ZTVN3icu14StringByteSinkISsEE]+0x30): undefined reference
 to `icu::ByteSink::Flush()'
transliterator.o:(.data.rel.ro._ZTIN3icu14StringByteSinkISsEE[_ZTIN3icu14StringByteSinkISsEE]+0x10): undefined reference
 to `typeinfo for icu::ByteSink'
./libmagic_ext.a(compress.o): In function `uncompressgzipped':
/home/rkmathi/.gem/ruby/2.0.0/gems/charlock_holmes-0.6.9.4/ext/charlock_holmes/src/file-5.08/src/compress.c:357: undefin
ed reference to `inflateInit2_'
/home/rkmathi/.gem/ruby/2.0.0/gems/charlock_holmes-0.6.9.4/ext/charlock_holmes/src/file-5.08/src/compress.c:363: undefin
ed reference to `inflate'
/home/rkmathi/.gem/ruby/2.0.0/gems/charlock_holmes-0.6.9.4/ext/charlock_holmes/src/file-5.08/src/compress.c:370: undefin
ed reference to `inflateEnd'
collect2: error: ld returned 1 exit status
make: *** [charlock_holmes.so] Error 1


Gem files will remain installed in /home/rkmathi/.gem/ruby/2.0.0/gems/charlock_holmes-0.6.9.4 for inspection.
Results logged to /home/rkmathi/.gem/ruby/2.0.0/gems/charlock_holmes-0.6.9.4/ext/charlock_holmes/gem_make.out

/usr/lib/ruby/2.0.0/x86_64-linux/rbconfig.rbのLDFLAGSを編集したら通りました。

CONFIG["LDFLAGS"] = "-L. -Wl,-O1 -Wl,--as-needed -rdynamic -Wl,-export-dynamic -Wl,--no-undefined"

という行を、

CONFIG["LDFLAGS"] = "-L. -Wl,-O1 -Wl,--as-needed -rdynamic -Wl,-export-dynamic"

にすればインストールできました。