1.依赖安装
Thrift的编译器使用C++编写的,在安装编译器之前,首先应该保证操作系统基本环境支持C++的编译,安装相关依赖的软件包,如下所示
sudo yum install automake libtool flex bison pkgconfig gcc-c++ boost-devel libevent-devel zlib-devel python-devel ruby-devel openssl-devel
2.thrift-0.9.1下载地址
wget http://archive.apache.org/dist/thrift/0.9.1/thrift-0.9.1.tar.gz
tar -xvzf thrift-0.9.1.tar.gz
cd thrift-0.9.1
./configure
make
# 此处可能报错ar: .libs/ThriftTest_constants.o: No such file or directory 解决办法:cp test/cpp/*.o test/cpp/.libs/
make install
3.验证是否安装成功
thrift -version
# 打印出版本号,说明成功
4.生成thrift文件对应的框架文件
java:
[[hadoop@master](mailto:hadoop@master) thrift]$ thrift --gen java user.thrift
C++:
[[hadoop@master](mailto:hadoop@master) thrift]$ thrift --gen cpp user.thrift
python:
[[hadoop@master](mailto:hadoop@master) thrift]$ thrift --gen py user.thrift
网友评论