Thrift|Thrift安装初体验

官网下载Thrift:

http://mirrors.hust.edu.cn/apache/thrift/0.9.3/thrift-0.9.3.tar.gz

首先需要构架和安装Thrift的编译器

http://thrift.apache.org/docs/BuildingFromSource

在安装源码之前,需要做好一些准备:

http://thrift.apache.org/docs/install/os_x

安装Boost

https://sourceforge.net/projects/boost/files/boost/1.61.0/https://sourceforge.net/projects/boost/files/boost/1.61.0/boost_1_61_0.tar.gz/download

执行

$ ./bootstrap.sh$ sudo ./b2 threading=multi address-model=64 variant=release stage install 

安装libevent

http://libevent.org/$ brew install libevent

我是通过brew安装的,prefix是/usr/local/Cellar.

安装Thrift

$ tar -zxvf thrift-0.9.3.tar.gz$ cd thrift-0.9.3$ ./configure --prefix=/data/thrift --with-boost=/data/thrift/boost_1_61_0 --with-libevent=/usr/local/Cellar

遇到报错,安装更高版本的bison

$ brew install homebrew/versions/bison27

安装成功

配置 .thrift 文件

安装完Thrift的编译器后,还需要完成一个配置文件。这个文件实际上是通过使用Thrift方式和服务来定义接口。定义好的配置文件即可被server以及其它任意的client使用。

从一个.thrift文件来生成source code,需要执行

thrift --gen  

可参考文件:

https://git-wip-us.apache.org/repos/asf/thrift/?p=thrift.git;a=tree;f=tutorialhttps://git-wip-us.apache.org/repos/asf/thrift/?p=thrift.git;a=blob;f=tutorial/php/PhpClient.php;h=d262b8fe922719034731679347410a90d81df5a3;hb=HEADhttps://git-wip-us.apache.org/repos/asf/thrift/?p=thrift.git;a=blob;f=tutorial/php/PhpServer.php;h=22ae43eb84d1a019a8622181a3eac3fc9468c147;hb=HEADRPC: http://baike.baidu.com/view/7287257.htm?fromtitle=RPC&fromid=609861&type=search

参考

  1. http://thrift.apache.org/

  2. http://thrift.apache.org/lib/php

  3. http://thrift.apache.org/static/files/thrift-20070401.pdf

关键字:thrift, 安装, brew, install


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部