1、在https://archive.apache.org/dist/thrift/位置选择相应的版本下载,如下图所示:
2、然后选择thrift-0.13.0.tar.gz下载,如下图所示:
3、通过wget https://archive.apache.org/dist/thrift/0.13.0/thrift-0.13.0.tar.gz命令下载,如下图所示:
4、下载好之后通过:tar -xzvf thrift-0.13.0.tar.gz解压,如下图所示:
5、在编译之前要先安装:
yum install libtool flex bison pkgconfig boost-devel libevent-devel zlib-devel python-devel ruby-devel openssl-devel ant
如下图所示:
6、然后进入到thrift目录,执行./bootstrap.sh,如下图所示:
7、然后执行./configure,这是默认的,也可以支持选择,如下命令:
./configure --with-cpp --with-boost=/usr/local/ --with-python --without-csharp --with-java --without-erlang --without-perl --without-php --without-php_extension --without-ruby --without-haskell --without-go
凡是--with选项的都让其编译,--without不编译
如下图所示:
发现不管是单独的configure还是加参数的执行结果都相同,如果想支持java,必要安装ant:
yum install ant
如果是想安装支持C++,则必须手动编译boost,编译方法是:
./bootstrap.sh
./b2 --without-python stage debug
cp -rf boost /usr/local/
cp -rf stage/lib/* /usr/local/lib64/
然后在执行:
./configure --with-cpp --with-boost=/usr/local/ --with-python --without-csharp --with-java --without-erlang --without-perl --without-php --without-php_extension --without-ruby --without-haskell --without-go
如下图所示:
8、然后执行make,此时会出现如下错误:
libtool: Version mismatch error. This is libtool 2.4.2, but the
libtool: definition of this LT_INIT comes from libtool 2.4.6.
libtool: You should recreate aclocal.m4 with macros from libtool 2.4.2
libtool: and run autoconf again.
make[3]: *** [thrift] 错误 63
make[3]: 离开目录“/usr/local/src/thrift-0.13.0/compiler/cpp”
make[2]: *** [all-recursive] 错误 1
make[2]: 离开目录“/usr/local/src/thrift-0.13.0/compiler/cpp”
make[1]: *** [all-recursive] 错误 1
make[1]: 离开目录“/usr/local/src/thrift-0.13.0”
make: *** [all] 错误 2
如下图所示:
9、然后执行autoreconf -ivf,再次执行make,如下图所示:
10、然后通过make install进行安装,如下图所示:
11、此时通过thrift --version来查看版本号,如下图所示:
12、到此完成编译。