Search code examples
c++thrift

Error while compiling Thrift Server


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]â:


Solution

  • seems as though you have a problem with htons(), htonl() functions missing, have you included the correct header?

    #include <arpa/inet.h>