---
title: "又一次安装thrift"
author: "digiter"
date: "2012-02-18T12:25:44Z"
tags: []
categories: ["编程语言"]
slug: "thrift"
draft: false
lastmod: "2012-02-21T18:28:45Z"
id: 1409939
url: "https://digiter.iteye.com/blog/1409939"
---

with cpp, java, python


make install搞了N次，Ant总提示JAVA_HOME不对
最后看这篇博文<http://jayant7k.blogspot.com/2010/04/intro-to-thrift.html>原来需要管理员权限，su一下，再export JAVA_HOME...

另外make自带的tutorial cpp的时候总提示undefined reference...
原来是G++版本的问题...最后我是用4.4.6版本搞定的
see http://mail-archives.apache.org/mod_mbox/thrift-user/201107.mbox/%3C4E3180C3.10204@ens-lyon.fr%3E


> I also tried to compile with various g++ version:
> 
> g++ 4.4.6: OK
> 
> g++ 4.5.3: OK
> 
> g++ 4.6.1: complains about undefined reference to 
> `apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::VERSION_1'
> 
> and undefined reference to 
> `apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::VERSION_MASK'


然后还得添加两个宏进去，thrift0.8.0真是开发中版本。。。。。
-DHAVE_NETINET_IN_H -DHAVE_INTTYPES_H
这两个宏都是定义在/usr/local/include/thrift/Thrift.h中的

```

g++ -DHAVE_NETINET_IN_H -DHAVE_INTTYPES_H -o CppClient  -I/usr/local/include/thrift -I/usr/include/boost  -I../gen-cpp -L/usr/local/lib -L/usr/lib -lthrift CppClient.cpp ../gen-cpp/SharedService.cpp ../gen-cpp/shared_types.cpp ../gen-cpp/tutorial_types.cpp ../gen-cpp/Calculator.cpp

```