thrift裏自帶的turoral,使用make編譯時經常會報錯,總結如下:
1.如果出現如下錯誤:
error: ‘uint8_t’ does not name a typeerror: ‘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