现在的位置: 首页 > 综合 > 正文

thrift经常遇到的问题

2016年09月17日 ⁄ 综合 ⁄ 共 964字 ⁄ 字号 评论关闭

thrift里自带的turoral,使用make编译时经常会报错,总结如下:

1.如果出现如下错误:

              error: ‘uint8_t’ does not name a type

                error: ‘uint32_t’ does not name a type

编译时需要加上:-DHAVE_NETINET_IN_H

如果是在cdt里编译,需要在工程配置-》C/C++ Build/Settings->Tool Settings->GCC C++ Compiler->Preprocessor->Defined Symbols(-D)中添加HAVE_NETINET_IN_H即可

2.如果出现:

 1)undefined reference to `apache::thrift::TApplicationException::write(apache::thrift::protocol::TProtocol*) const'

 2)complains about undefined reference to
`apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::VERSION_1'

需要修改/usr/include/thrift/protocol/TBinaryProtocol.h

中的:

static const int32_t VERSION_MASK = 0xffff0000;
static const int32_t VERSION_1 = 0x80010000

static const uint32_t VERSION_MASK = 0xffff0000;
static const uint32_t VERSION_1 = 0x80010000;

3.如果还报错:

undefined reference to `apache::thrift::transport::TServerSocket::TServerSocket等错误,需要修改makfile,把编译命令里的-lthrift挪到命令的后边,即待编译文件之后

最后,thrift的使用例程还可以参考官方的wiki:

http://wiki.apache.org/thrift/ThriftUsageC%2B%2B

抱歉!评论已关闭.