1、代码下载
从网上可以直接下载,http://www.apache.org/dyn/closer.cgi?path=/thrift/0.10.0/thrift-0.10.0.tar.gz
也可以用git从github上下载 git clone https://git-wip-us.apache.org/repos/asf/thrift.git
2、环境准备:
服务器的linux事centos6.7的,所以这里只列出centos6的
Building Apache Thrift on CentOS 6.5
Starting with a minimal installation, the following steps are required to build Apache Thrift on Centos 6.5. This example builds from source, using the current development master branch. These instructions should also work with Apache Thrift releases beginning with 0.9.2.
Update the System
sudo yum -y update
Install the Platform Development Tools
sudo yum -y groupinstall "Development Tools"
Upgrade autoconf/automake/bison
sudo yum install -y wget
Upgrade autoconf
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz tar xvf autoconf-2.69.tar.gz cd autoconf-2.69 ./configure --prefix=/usr make sudo make install cd ..
Upgrade automake
wget http://ftp.gnu.org/gnu/automake/automake-1.14.tar.gz tar xvf automake-1.14.tar.gz cd automake-1.14 ./configure --prefix=/usr make sudo make install cd ..
Upgrade bison
wget http://ftp.gnu.org/gnu/bison/bison-2.5.1.tar.gz tar xvf bison-2.5.1.tar.gz cd bison-2.5.1 ./configure --prefix=/usr make sudo make install cd ..
Add Optional C++ Language Library Dependencies
All languages require the Apache Thrift IDL Compiler and at this point everything needed to make the IDL Compiler is installed (if you only need the compiler you can skip to the Build step).
If you will be developing Apache Thrift clients/servers in C++ you will also need additional packages to support the C++ shared library build.
Install C++ Lib Dependencies
sudo yum -y install libevent-devel zlib-devel openssl-devel
Upgrade Boost >= 1.53
wget http://sourceforge.net/projects/boost/files/boost/1.53.0/boost_1_53_0.tar.gz tar xvf boost_1_53_0.tar.gz cd boost_1_53_0 ./bootstrap.sh sudo ./b2 install
安装java 安装 ant
yum install ant
不安装ant的话,configure的时候会发现不支持java:
**Building Java Library ........ : no**
Build and Install the Apache Thrift IDL Compiler
git clone https://git-wip-us.apache.org/repos/asf/thrift.git cd thrift ./bootstrap.sh ./configure --with-lua=no make sudo make install
3、编译中出现的问题解决:
(1) 第一个出现的问题是:
找不到 event2/event_compat.h文件
解决方法: 下载libevent最新的版本,然后安装后即可
(2)第二个问题
src/thrift/server/TNonblockingServer.cpp: In member function ‘void apache::thrift::server::TNonblockingServer::TConnection::workSocket()‘:
src/thrift/server/TNonblockingServer.cpp:460:16: error: expected ‘)‘ before ‘PRIu32‘
"(%" PRIu32 " > %" PRIu64
解决方法:
更改了文件:src/thrift/Thrift.h,最后编译成功,更改内容如下:
#ifdef HAVE_INTTYPES_H
#define __STDC_FORMAT_MACROS
#include
#endif
(3)第三个问题
src/thrift/transport/THeaderTransport.h 中TVirtualTransport没有定义的错误
解决方法:
在改头文件中提示出错的TVirtualTransport改成TVirtualTransport