thrift安装(Mac版)

本文详细介绍了在Mac上安装Thrift的三种方法:通过brew安装最新版、安装0.9版本以及安装0.8.0版本。包括具体命令行操作、环境变量配置以及安装过程中的注意事项和版本验证。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

尝试地安装了一下thrift,折腾了好久,简单总结如下。

一、最新版

可以使用brew安装最新版的thrift,命令:brew install thrift

二、安装0.9版本

1、安装thrift

在终端输入命令(注意需要安装的thrift版本):brew install thrift@0.9

注意:安装时间可能较长,请耐心等待

2、安装成功后,修改配置

sudo vim ~/.bash_profile

添加:export PATH="/usr/local/opt/thrift@0.9/bin:$PATH",保存

source .bash_profile,使配置修改生效

在终端输入:thrift -version,查看thrift安装是否成功及版本号

三、安装0.8.0版本(转载https://blog.youkuaiyun.com/nitpicking/article/details/78877500

这一版本比较麻烦

  1. 安装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

    执行时间较长

  2. 安装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

     

  3. 安装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验证是否安装成功。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值