Chinaunix首页 | 论坛 | 博客
  • 博客访问: 147657
  • 博文数量: 53
  • 博客积分: 1776
  • 博客等级: 上尉
  • 技术积分: 545
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-05 00:17
文章分类

全部博文(53)

文章存档

2016年(1)

2013年(2)

2012年(11)

2011年(6)

2010年(9)

2009年(19)

2008年(5)

我的朋友

分类: LINUX

2011-12-30 14:42:20

thrift 安装文档

一、install jdk for linux

安装JDK 具体内容参照 tomcat安装文档。

二、install ant

 1、下载最新版的ant

wget

 2、tar xzvf apache-ant-1.8.2-bin.tar.gz -C /usr/local/
 3、vim /etc/profile,添加
 ANT_HOME=/usr/local/apache-ant-1.8.2
 PATH=$ANT_HOME/bin:$PATH
 4、保存退出,执行 source /etc/profile

三、install thrift

1、检查安装需求
 1) g++ 3.3.5+,一般系统缺省就可以
 # boost 1.33.1+ (1.34.0 for building all tests),
 需要使用yum search boost来查询,执行 yum install boost.x86_64来安装,如果是32位系统,改为yum install boost.i386
 2) Runtime libraries for lex and yacc might be needed for the compiler. (flex库),
 需要使用yum search flex来查询,执行 yum install flex.x86_64 来安装
 3)安装语言支持库
  yum install automake libtool flex bison pkgconfig gcc-c++ boost-devel libevent-devel zlib-devel python-devel glibc-devel glibc glib2 glib2-devel
 4)安装php
  yum -y install php
2、安装

#wget
#tar -zxvf thrift-0.7.0.tar.gz -C /usr/local/
#chown -R root:root /usr/local/thrift-0.7.0/
#cd /usr/local/thrift-0.7.0/
#chmod 755 configure
支持php,python,c/c++,java
#./configure --prefix=/usr/local/ --with-boost=/usr/local --with-csharp --without-perl --with-php --with-php_extension --without-haskell --with-c_glib --with-java --with-python
#make
#make install


四、验证方法
在thrift源代码目录有一个叫tutorial的目录,进行其中后运行thrift命令生成相应的服务代码:
 
#thrift -r --gen cpp tutorial.thrift // -r对其中include的文件也生成服务代码 -gen是生成服务代码的语言 
 
运行完之后会在当前目录看到一个gen-cpp目录,其中就是thrfit命令生成的代码
 
这时你cd到tutorial/cpp目录,运行make,生成相应的CppServer与CppClient程式。
 
这时你可以用./CppServer运行服务端,让其监听一个特定的端口,默认为9090
 
这时在打开一个终端,用./CppClient运行客户端程式,让其去连接服务端,调用其所对应的服务。默认调用后会输出如下信息:
Starting the server...
ping()
add(1,1)
calculate(1,{4,1,0})
calculate(1,{2,15,10})
getStruct(1)

阅读(1881) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~