尝试地安装了一下thrift,折腾了好久,简单总结如下。
一、最新版
可以使用brew安装最新版的thrift,命令:brew install thrift
二、安装0.9版本
1、安装thrift
在终端输入命令(注意需要安装的thrift版本):brew install [email protected]
注意:安装时间可能较长,请耐心等待
2、安装成功后,修改配置
sudo vim ~/.bash_profile
添加:export PATH="/usr/local/opt/[email protected]/bin:$PATH",保存
source .bash_profile,使配置修改生效
在终端输入:thrift -version,查看thrift安装是否成功及版本号
三、安装0.8.0版本(转载https://blog.csdn.net/nitpicking/article/details/78877500)
这一版本比较麻烦
-
安装boost
下载地址:https://dl.bintray.com/boostorg/release/1.64.0/source/ (这里选择1.64.0版)
下载后解压到某个目录,在该目录下安装
./bootstrap.sh sudo ./b2 threading=multi address-model=64 variant=release stage install
执行时间较长
-
安装libevent
下载地址:http://libevent.org/ 选择libevent-2.1.8-stable.tar.gz版
下载后解压到某个目录,在该目录下安装
安装前需要安装一些openssl的include和lib库,否则报错。
brew install openssl brew link openssl --froce ln -s /usr/local/opt/openssl/bin/openssl /usr/local/bin/openssl ln -s /usr/local/opt/openssl/include/openssl /usr/local/include/openssl ln -s /usr/local/opt/openssl/lib/libssl.a /usr/local/lib/libssl.a ln -s /usr/local/opt/openssl/lib/libcrypto.a /usr/local/lib/libcrypto.a
然后再安装libevent
./configure --prefix=/usr/local make sudo make install
-
安装thrift
下载地址:http://archive.apache.org/dist/thrift/ 选择0.8.0
下载后解压到某个目录,在该目录下安装
安装之前修改一些文件,否则报错
1)将#include <tr1/functional>改为#include <boost/tr1/functional.hpp>
{thrift目录}/lib/cpp/src/concurrency/ThreadManager.h line:24 {thrift目录}/lib/cpp/src/async/TAsyncChannel.h line:23 {thrift目录}/lib/cpp/src/async/TAsyncChannel.cpp line:21 {thrift目录}/lib/cpp/src/async/TAsyncProcessor.h line:23 {thrift目录}/lib/cpp/src/async/TAsyncBufferProcessor.h line:23
2)用 boost::shared_ptr 替换 shared_ptr(一共有两处),需要修改的文件如下,
{thrift目录}/lib/cpp/test/Benchmark.cpp
修改好了,就可以安装thrift
./configure --prefix=/usr/local/ --with-boost=/usr/local --with-libevent=/usr/local --without-ruby --without-php make sudo make install
最后,使用thrift -version验证是否安装成功。