2014年4月7日月曜日

Apache ThriftをCentOS6にインストール

HawkinsSteven

Apache Thrift(http://thrift.apache.org/)をCentOS6にインストールしようとしたのですが、エラーが出て一瞬ハマったので正解をメモしておきます。

Thriftインストールが駄目なパターン

# ./configure
# make
~~~~
libtool: link: g++ -Wall -g -O2 -o .libs/TutorialClient CppClient.o  -L/usr/lib ./.libs/libtutorialgencpp.a /usr/local/src/thrift-0.9.1/lib/cpp/.libs/libthrift.so ../../lib/cpp/.libs/libthrift.so -lssl -lcrypto -lrt -lpthread -Wl,-rpath -Wl,/usr/local/lib
make[3]: ディレクトリ `/usr/local/src/thrift-0.9.1/tutorial/cpp' から出ます
Making all in py
make[3]: ディレクトリ `/usr/local/src/thrift-0.9.1/tutorial/py' に入ります
../../compiler/cpp/thrift --gen py -r ../../tutorial/tutorial.thrift
make[3]: ディレクトリ `/usr/local/src/thrift-0.9.1/tutorial/py' から出ます
Making all in py.twisted
make[3]: ディレクトリ `/usr/local/src/thrift-0.9.1/tutorial/py.twisted' に入ります
../../compiler/cpp/thrift --gen py:twisted -r ../../tutorial/tutorial.thrift
make[3]: ディレクトリ `/usr/local/src/thrift-0.9.1/tutorial/py.twisted' から出ます
Making all in py.tornado
make[3]: ディレクトリ `/usr/local/src/thrift-0.9.1/tutorial/py.tornado' に入ります
../../compiler/cpp/thrift --gen py:tornado -r ../../tutorial/tutorial.thrift
make[3]: ディレクトリ `/usr/local/src/thrift-0.9.1/tutorial/py.tornado' から出ます
make[3]: ディレクトリ `/usr/local/src/thrift-0.9.1/tutorial' に入ります
../compiler/cpp/thrift --gen html -r ../tutorial/tutorial.thrift
make[3]: ディレクトリ `/usr/local/src/thrift-0.9.1/tutorial' から出ます
make[2]: ディレクトリ `/usr/local/src/thrift-0.9.1/tutorial' から出ます
Making all in test
make[2]: ディレクトリ `/usr/local/src/thrift-0.9.1/test' に入ります
Making all in nodejs
make[3]: ディレクトリ `/usr/local/src/thrift-0.9.1/test/nodejs' に入ります
make[3]: `all' に対して行うべき事はありません.
make[3]: ディレクトリ `/usr/local/src/thrift-0.9.1/test/nodejs' から出ます
Making all in cpp
make[3]: ディレクトリ `/usr/local/src/thrift-0.9.1/test/cpp' に入ります
Makefile:832: 警告: ターゲット `gen-cpp/ThriftTest.cpp' へのコマンドを置き換えます
Makefile:829: 警告: ターゲット `gen-cpp/ThriftTest.cpp' への古いコマンドは無視されます
/bin/sh ../../libtool --tag=CXX   --mode=link g++ -Wall -g -O2 -L/usr/lib   -o libtestgencpp.la  ThriftTest_constants.lo ThriftTest_types.lo ../../lib/cpp/libthrift.la -lssl -lcrypto -lrt -lpthread
libtool: link: ar cru .libs/libtestgencpp.a .libs/ThriftTest_constants.o .libs/ThriftTest_types.o
ar: .libs/ThriftTest_constants.o: No such file or directory
make[3]: *** [libtestgencpp.la] エラー 1
make[3]: ディレクトリ `/usr/local/src/thrift-0.9.1/test/cpp' から出ます
make[2]: *** [all-recursive] エラー 1
make[2]: ディレクトリ `/usr/local/src/thrift-0.9.1/test' から出ます
make[1]: *** [all-recursive] エラー 1
make[1]: ディレクトリ `/usr/local/src/thrift-0.9.1' から出ます

make: *** [all] エラー 2


Thriftインストールが成功するパターン

configure時にオプションを追加します。
cppのライブラリのインストールをスルーしています。

# wget http://ftp.kddilabs.jp/infosystems/apache/thrift/0.9.1/thrift-0.9.1.tar.gz
# tar vzxf thrift-0.9.1.tar.gz
# ./configure --with-cpp=no
# make
# make install
# ln -s /usr/local/bin/thrift /usr/bin/thrift

GitHubにFabricスクリプトを置いておきました。
https://github.com/takeshiyako2/fabric-scripts/blob/master/centos6-thrift.py