CentOS 7 安装 Thrift-0.10.0(亲测)

本贴最后更新于 1956 天前,其中的信息可能已经事过境迁

1. 升级所有软件包

yum -y update

2.安装开发工具

yum -y groupinstall "Development Tools"

3.安装 autoconf/automake/bison/boost

autoconf 和 automake 两个工具来帮助我们自动地生成符合自由软件惯例的 Makefile GNU
bison 是属于 GNU 项目的一个语法分析器生成器。
bison 把一个关于“向前查看 从左到右 最右”(LALR) 上下文无关文法的描述转化成可以分析该文法的 C 或 C++ 程序。
它也可以为二义文法生成 “通用的 从左到右 最右” (GLR)语法分析器。(from 百度百科

wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
tar -zxvf autoconf-2.69.tar.gz
cd autoconf-2.69 ./configure --prefix=/usr
make
make install
wget http://ftp.gnu.org/gnu/automake/automake-1.14.tar.gz
tar -zxvf automake-1.14.tar.gz
cd automake-1.14 ./configure --prefix=/usr
make
make install
wget http://ftp.gnu.org/gnu/bison/bison-2.5.1.tar.gz
tar -zxvf bison-2.5.1.tar.gz
cd bison-2.5.1 ./configure --prefix=/usr
make
make install
wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz 
tar -xvf boost_1_59_0.tar.gz 
cd boost_1_59_0 
./bootstrap.sh 
./b2 install

4. 安装 C++ 依赖

yum -y install libevent-devel zlib-devel openssl-devel

5.安装 thrift ,不要用 git 包,直接到官网上下载 tar 包

wget http://apache.fayea.com/thrift/0.10.0/thrift-0.10.0.tar.gz 
tar -xvf thrift-0.10.0.tar.gz 
cd thrift-0.10.0 
./configure --with-lua=no 
make && make install

6.安装错误及解决方案

1.找不到 libboost_unit_test_framework.a;
解决:源码本地编译 boost 安装;

2.gcc 宏编译问题__STDC_FORMAT_MACROS
解决:不要用 git 包,昂 ~,因为使用 git 包在安装的时候会报

src/thrift/server/TNonblockingServer.cpp:460:16: 
错误:expected ‘)’ before ‘PRIu32’
"(%" PRIu32 " > %" PRIu64
                ^

7.测试下 thrift 是否安装成功,使用 thrift 官网的例子

在/home/thrift_test 目录下创建 user.thrift 文件,内容如下:

struct UserProfile { 1: i32 uid, 2: string name, 3: string blurb
}
service UserStorage { void store(1: UserProfile user),
UserProfile retrieve(1: i32 uid)
}

执行 thrift --gen php user.thrift

在当前目录下生成一个目录 gen-php,打开 gen-php 目录,有两个文件,如下

[root@MiWiFi-R3-srv thrift_test]# cd gen-php/ [root@MiWiFi-R3-srv gen-php]# ll
总用量 16
-rw-r--r--. 1 root root 3258 7 月 29 20:30 Types.php -rw-r--r--. 1 root root 10359 7 月 29 20:30 UserStorage.php

到此,thrift 安装成功

  • B3log

    B3log 是一个开源组织,名字来源于“Bulletin Board Blog”缩写,目标是将独立博客与论坛结合,形成一种新的网络社区体验,详细请看 B3log 构思。目前 B3log 已经开源了多款产品:SymSoloVditor思源笔记

    1090 引用 • 3467 回帖 • 297 关注
  • thrift
    1 引用 • 5 回帖 • 1 关注
  • RPC
    16 引用 • 22 回帖

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...