编译 Thrift 服务器时出错
我是 Thrift 新手:http://thrift.apache.org/ 我正在使用 CentOS,并且“也许”成功安装了 Thrift。我可以使用 thrift 来生成代码。 但请按照说明进行操作: http://wiki.apache.org/thrift/ThriftUsageC%2B% 2B 编译 Something_server.cpp 时出现错误 请知道的人帮我找出原因。我不知道。非常感谢
我使用thrift让PHP调用C++来做只有C++才能做的工作。 有人对我有其他建议吗?谢谢
[root@localhost gen-cpp]# g++ -Wall -I/usr/local/include/thrift *.cpp -lthrift -o 某事 /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数“uint32_t apache::thrift::protocol::TBinaryProtocolT::writeI16(int16_t)”中: /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147: 错误:“htons” 没有依赖于模板参数的参数,因此“htons” 声明必须可用 /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147: 错误:(如果您使用“-fpermissive”,G++ 将接受您的代码,但不推荐使用未声明的名称) /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数“uint32_t apache::thrift::protocol::TBinaryProtocolT::writeI32(int32_t)”中: /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:154: 错误:“htonl” 没有依赖于模板参数的参数,因此“htonl” 声明必须可用 Something_server.cpp:在成员函数“virtual int32_t SomethingHandler::ping()”中: Something_server.cpp:28:警告:函数中没有 return 语句返回非 void /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数 âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI16(int16_t) 中 [with Transport_ = apache::thrift::transport::TTransport]一个: /usr/local/include/thrift/protocol/TVirtualProtocol.h:401:从 âuint32_t apache::thrift::protocol::TVirtualProtocol::writeI16_virt(int16_t) 实例化 [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT , 超级_= apache::thrift::协议::TProtocolDefaults]â Something_server.cpp:42:从这里实例化 /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147: 错误: âhtonsâ 未在此范围内声明 /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数 âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI32(int32_t) 中 [with Transport_ = apache::thrift::transport::TTransport]一个: /usr/local/include/thrift/protocol/TVirtualProtocol.h:405:从 âuint32_t apache::thrift::protocol::TVirtualProtocol::writeI32_virt(int32_t) 实例化 [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT , 超级_= apache::thrift::协议::TProtocolDefaults]â Something_server.cpp:42:从这里实例化 /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:154: 错误: âhtonlâ 未在此范围内声明 /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数 âuint32_t apache::thrift::protocol::TBinaryProtocolT::readI16(int16_t&) 中 [with Transport_ = apache::thrift::transport::TTransport ]一个: /usr/local/include/thrift/protocol/TVirtualProtocol.h:499:从 âuint32_t apache::thrift::protocol::TVirtualProtocol::readI16_virt(int16_t&) 实例化 [with Protocol_ = apache::thrift::protocol:: TBinaryProtocolT,Super_ = apache::thrift::协议::TProtocolDefaults]â Something_server.cpp:42:从这里实例化 /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:362: 错误: antohsâ 未在此范围内声明 /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数 âuint32_t apache::thrift::protocol::TBinaryProtocolT::readI32(int32_t&) 中 [with Transport_ = apache::thrift::transport::TTransport ]一个: /usr/local/include/thrift/protocol/TVirtualProtocol.h:503:从 âuint32_t apache::thrift::protocol::TVirtualProtocol::readI32_virt(int32_t&) 实例化 [with Protocol_ = apache::thrift::protocol:: TBinaryProtocolT,Super_ = apache::thrift::协议::TProtocolDefaults]â Something_server.cpp:42:从这里实例化 /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:373: 错误: ântohlâ 未在此范围内声明 /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数“uint32_t apache::thrift::protocol::TBinaryProtocolT::writeI16(int16_t)”中: /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147: 错误:“htons” 没有依赖于模板参数的参数,因此“htons” 声明必须可用 /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147: 错误:(如果您使用“-fpermissive”,G++ 将接受您的代码,但不推荐使用未声明的名称) /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数“uint32_t apache::thrift::protocol::TBinaryProtocolT::writeI32(int32_t)”中: /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:154: 错误:“htonl” 没有依赖于模板参数的参数,因此“htonl” 声明必须可用 Something_server.骨骼.cpp:在成员函数“virtual int32_t SomethingHandler::ping()”中: Something_server.骨骼.cpp:28:警告:返回非 void 的函数中没有 return 语句 /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数 âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI16(int16_t) 中 [with Transport_ = apache::thrift::transport::TTransport]一个: /usr/local/include/thrift/protocol/TVirtualProtocol.h:401:从 âuint32_t apache::thrift::protocol::TVirtualProtocol::writeI16_virt(int16_t) 实例化 [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT , 超级_= apache::thrift::协议::TProtocolDefaults]â Something_server.骨骼.cpp:42:从这里实例化 /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147: 错误: âhtonsâ 未在此范围内声明 /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数 âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI32(int32_t) 中 [with Transport_ = apache::thrift::transport::TTransport]一个: /usr/local/include/thrift/protocol/TVirtualProtocol.h:405:从 âuint32_t apache::thrift::protocol::TVirtualProtocol::writeI32_virt(int32_t) 实例化 [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT , 超级_= apache::thrift::协议::TProtocolDefaults]â Something_server.骨骼.cpp:42:从这里实例化 /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:154: 错误: âhtonlâ 未在此范围内声明 /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数 âuint32_t apache::thrift::protocol::TBinaryProtocolT::readI16(int16_t&) 中 [with Transport_ = apache::thrift::transport::TTransport ]â:
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]â:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在我的系统(Ubuntu 10.10)上,htons() 和 htonl() 在 netinet/in.h 中声明。
我遇到了同样的错误,在构建 Thrift 服务器时,我通过将 -DHAVE_NETINET_IN_H 添加到 g++ 命令行参数来修复它。
这将导致预处理器将 netinet/in.h 包含在 thrift/protocol/TPrototol.h 中,因此 hton* 声明将对编译器可见。
TProtocol.h 中的以下几行在未定义 HAVE_NETINET_IN_H 时会导致编译器错误。
这可能是 Thrift 配置脚本中的一个错误,它以某种方式跳过了定义。
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.
This might be a bug in the Thrift configure script which somehow skips the define.
似乎您的 htons()、htonl() 函数缺失有问题,您是否包含了正确的标头?
#include
seems as though you have a problem with htons(), htonl() functions missing, have you included the correct header?
#include <arpa/inet.h>
从 Gmane 你需要一些#define。
将
-DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H
添加到您的 Makefile 中。例如。在生成文件中
From Gmane you need a few #defines.
Add in
-DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H
to your Makefile.Eg. In the Makefile