Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while compiling Thrift Server

Tags:

c++

thrift

I am new to Thrift : http://thrift.apache.org/ I am using CentOS, and "maybe" install Thrift succesfully. I can use thrift to generate codes. But Follow the instruction: http://wiki.apache.org/thrift/ThriftUsageC%2B%2B I get the Error while compile the Something_server.cpp Someone know pls help me to find out the reason. I have no idea. Thank you very much

I use thrift to let PHP to call C++ to do a job that only C++ can do. Any one have another suggestion for me ? Thank you

[root@localhost gen-cpp]# g++ -Wall -I/usr/local/include/thrift *.cpp -lthrift -o something /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI16(int16_t)â: /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147: error: there are no arguments to âhtonsâ that depend on a template parameter, so a declaration of âhtonsâ must be available /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147: error: (if you use â-fpermissiveâ, G++ will accept your code, but allowing the use of an undeclared name is deprecated) /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI32(int32_t)â: /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:154: error: there are no arguments to âhtonlâ that depend on a template parameter, so a declaration of âhtonlâ must be available Something_server.cpp: In member function âvirtual int32_t SomethingHandler::ping()â: Something_server.cpp:28: warning: no return statement in function returning non-void /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI16(int16_t) [with Transport_ = apache::thrift::transport::TTransport]â: /usr/local/include/thrift/protocol/TVirtualProtocol.h:401: instantiated from âuint32_t apache::thrift::protocol::TVirtualProtocol::writeI16_virt(int16_t) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT, Super_ = apache::thrift::protocol::TProtocolDefaults]â Something_server.cpp:42: instantiated from here /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147: error: âhtonsâ was not declared in this scope /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI32(int32_t) [with Transport_ = apache::thrift::transport::TTransport]â: /usr/local/include/thrift/protocol/TVirtualProtocol.h:405: instantiated from âuint32_t apache::thrift::protocol::TVirtualProtocol::writeI32_virt(int32_t) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT, Super_ = apache::thrift::protocol::TProtocolDefaults]â Something_server.cpp:42: instantiated from here /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:154: error: âhtonlâ was not declared in this scope /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::readI16(int16_t&) [with Transport_ = apache::thrift::transport::TTransport]â: /usr/local/include/thrift/protocol/TVirtualProtocol.h:499: instantiated from âuint32_t apache::thrift::protocol::TVirtualProtocol::readI16_virt(int16_t&) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT, Super_ = apache::thrift::protocol::TProtocolDefaults]â Something_server.cpp:42: instantiated from here /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:362: error: ântohsâ was not declared in this scope /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::readI32(int32_t&) [with Transport_ = apache::thrift::transport::TTransport]â: /usr/local/include/thrift/protocol/TVirtualProtocol.h:503: instantiated from âuint32_t apache::thrift::protocol::TVirtualProtocol::readI32_virt(int32_t&) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT, Super_ = apache::thrift::protocol::TProtocolDefaults]â Something_server.cpp:42: instantiated from here /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:373: error: ântohlâ was not declared in this scope /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI16(int16_t)â: /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147: error: there are no arguments to âhtonsâ that depend on a template parameter, so a declaration of âhtonsâ must be available /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147: error: (if you use â-fpermissiveâ, G++ will accept your code, but allowing the use of an undeclared name is deprecated) /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI32(int32_t)â: /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:154: error: there are no arguments to âhtonlâ that depend on a template parameter, so a declaration of âhtonlâ must be available Something_server.skeleton.cpp: In member function âvirtual int32_t SomethingHandler::ping()â: Something_server.skeleton.cpp:28: warning: no return statement in function returning non-void /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI16(int16_t) [with Transport_ = apache::thrift::transport::TTransport]â: /usr/local/include/thrift/protocol/TVirtualProtocol.h:401: instantiated from âuint32_t apache::thrift::protocol::TVirtualProtocol::writeI16_virt(int16_t) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT, Super_ = apache::thrift::protocol::TProtocolDefaults]â Something_server.skeleton.cpp:42: instantiated from here /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147: error: âhtonsâ was not declared in this scope /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI32(int32_t) [with Transport_ = apache::thrift::transport::TTransport]â: /usr/local/include/thrift/protocol/TVirtualProtocol.h:405: instantiated from âuint32_t apache::thrift::protocol::TVirtualProtocol::writeI32_virt(int32_t) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT, Super_ = apache::thrift::protocol::TProtocolDefaults]â Something_server.skeleton.cpp:42: instantiated from here /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:154: error: âhtonlâ was not declared in this scope /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::readI16(int16_t&) [with Transport_ = apache::thrift::transport::TTransport]â:

like image 592
Summer Nguyen Avatar asked Jan 18 '23 03:01

Summer Nguyen


1 Answers

On my system (Ubuntu 10.10), htons() and htonl() are declared in netinet/in.h.

I had the same error, and I fixed it by adding -DHAVE_NETINET_IN_H to the g++ command line parameters when building my Thrift server.

This will cause the preprocessor to include netinet/in.h in thrift/protocol/TPrototol.h, so the hton* declarations will be visible to the compiler.

TProtocol.h has the following lines which cause the compiler error when HAVE_NETINET_IN_H is not defined.

#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif

This might be a bug in the Thrift configure script which somehow skips the define.

like image 154
Dmitri Bouianov Avatar answered Jan 25 '23 21:01

Dmitri Bouianov