Thriftインストール

Thriftを業務で今後利用するかもしれないので少し調べています。
ただ、インストールでつまづいてた。。
普通に公式サイトに書いてあるようにやれば上手くインストールできるのです。
FrontPage Thrift Wiki
ただ、FAQもよく読んでおくべきだった。。それだけ。

一応メモ。
今回はMacbookにインストールしました。
Thriftはboostが必須なので注意。公式サイトにはSo please download the bzip2 of boost and unpack〜〜とか書いてありますが、portでインストールしてしまいます。

$ sudo port install boost

インストールに失敗する場合は一度cleanしてみる。

$ sudo port clean --work boost

環境変数の設定も忘れずに(.bashrc, .zshrc …)。

export PATH=/opt/local/bin:/opt/local/sbin/:$PATH
export MANPATH=/opt/local/man:$MANPATH
export LIBRARY_PATH=/opt/local/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=/opt/local/lib:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=/opt/local/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/opt/local/include:$CPLUS_INCLUDE_PATH
export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib
export BOOST_ROOT=/opt/local/include/boost:$BOOST_ROOT

あとはThrift本体をインストールするだけです。

$ wget -O thrift.tgz "http://gitweb.thrift-rpc.org/?p=thrift.git;a=snapshot;h=HEAD;sf=tgz"
$ tar -xzf thrift.tgz
$ cd thrift
$ ./bootstrap.sh
$ ./configure
$ make
$ sudo make install

ただ、僕の場合 ./configure で以下のようなエラーがでました。

./configure: line 21183: syntax error near unexpected token `MONO,'
./configure: line 21183: `  PKG_CHECK_MODULES(MONO, mono >= 1.2.6, have_mono=yes, have_mono=no)'

意味がわからなくて途方に暮れていたんですが、公式のFAQに解決策が書いてありました。。
FAQ – Thrift Wiki
If you’re on OS X: find pkg.m4, copy it to thrift/aclocal, and rerun bootstrap.sh.
とあるので、とりあえず /opt/local/share/aclocal に pkg.m4 があるか確認してからcopy。
(pkgconfigパッケージがインストールされている必要がある)

$ cp /opt/local/share/aclocal/pkg.m4 ./aclocal
$ ./bootstrap.sh
.... 略

make install まで上手くいきました。
公式にドキュメントがある場合はFAQも含めてよく読もう。

<追記>
各言語のライブラリのインストールも忘れないように。
ここでは、perl, ruby, pythonの各ライブラリをインストールしておきます。

$ cd lib/perl
$ perl Makefile.PL
$ sudo make install
$ cd ../rb
$ sudo ruby setup.rb
$ cd ../py
$ sudo python setup.py install

あわせて読む:

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です