当前位置:  开发笔记 > 编程语言 > 正文

编译Thrift服务器时出错

如何解决《编译Thrift服务器时出错》经验,为你挑选了1个好方法。

我是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 something /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数中âint32_tapache :: 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:在成员函数中,âint32_tapache:: thrift :: protocol :: TBinaryProtocolT :: writeI32(int32_t)â:/ usr/local/include/thrift/protocol/TBinaryProtocol .tcc:154:错误:没有依赖于模板参数的âhtonlâ的参数,因此必须提供âhtonlâ的声明Something_server.cpp:在成员函数中âvirtu al int32_t SomethingHandler :: ping()â:Something_server.cpp:28:警告:函数中没有return语句返回non-void /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数中âint32_tapache :: thrift :: protocol :: TBinaryProtocolT :: writeI16(int16_t)[与Transport_ = apache :: thrift :: transport :: TTransport]â:/usr/local/include/thrift/protocol/TVirtualProtocol.h:401:从âint32_tapache实例化:: thrift :: protocol :: TVirtualProtocol :: writeI16_virt(int16_t)[with Protocol_ = apache :: thrift :: protocol :: TBinaryProtocolT,Super_ = apache :: thrift :: protocol :: TProtocolDefaults]âSomething_server.cpp:42:从这里实例化/usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147:错误:âthtonsâ未在此范围内声明/usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数âint32_tapache中: :thrift :: protocol :: TBinaryProtocolT :: writeI32(int32_t)[与Transport_ = apache :: thrift :: transport :: TTransport]â:/ usr/local/include/thrift/pro tocol/TVirtualProtocol.h:405:从âint32_t实现apache :: thrift :: protocol :: TVirtualProtocol :: writeI32_virt(int32_t)[with Protocol_ = apache :: thrift :: protocol :: TBinaryProtocolT,Super_ = apache :: thrift :: protocol :: TProtocolDefaults]âSomething_server.cpp:42:从这里实例化/usr/local/include/thrift/protocol/TBinaryProtocol.tcc:154:错误:âhtonlâ未在此范围内声明/ usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数âintint32_tapache :: thrift :: protocol :: TBinaryProtocolT :: readI16(int16_t&)[与Transport_ = apache :: thrift :: transport :: TTransport]â:/ usr/local/include/thrift/protocol/TVirtualProtocol.h:499:从âint32_t实现apache :: thrift :: protocol :: TVirtualProtocol :: readI16_virt(int16_t&)[with Protocol_ = apache :: thrift :: protocol :: TBinaryProtocolT,Super_ = apache :: thrift :: protocol :: TProtocolDefaults]âSomething_server.cpp:42:从这里实例化/usr/local/include/thrift/protocol/TBinaryProtocol.tcc:362:错误:ân tohsâ未在此范围内声明/usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数âintint32_tapache :: thrift :: protocol :: TBinaryProtocolT :: readI32(int32_t&)[with Transport_ = apache :: thrift :: transport :: TTransport]â:/usr/local/include/thrift/protocol/TVirtualProtocol.h:503:从âint32_t实现apache :: thrift :: protocol :: TVirtualProtocol :: readI32_virt(int32_t&)[with Protocol_ = apache :: thrift :: protocol :: TBinaryProtocolT,Super_ = apache :: thrift :: protocol :: TProtocolDefaults]âSomething_server.cpp:42:从这里实例化/usr/local/include/thrift/protocol/TBinaryProtocol.tcc:373:错误:ântohlâ未在此范围内声明/usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数âintint32_tapache :: thrift :: protocol :: TBinaryProtocolT :: writeI16(int16_t)â:/ usr/local /include/thrift/protocol/TBinaryProtocol.tcc:147:错误:没有依赖于模板参数的âhtonsâ的参数,所以âhtonsâmus的声明 可用/usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147:错误:(如果你使用'fpermissiveâ,G ++将接受你的代码,但允许使用未声明的名称已被弃用)/ usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数âintint32_tapache :: thrift :: protocol :: TBinaryProtocolT :: writeI32(int32_t)â:/usr/local/include/thrift/protocol/TBinaryProtocol.tcc:154 :错误:没有依赖于模板参数的âhtonlâ的参数,因此必须提供âhtonlâ的声明Something_server.skeleton.cpp:在成员函数中 - 虚拟int32_t SomethingHandler :: ping()â:Something_server.skeleton.cpp:28 :警告:函数中没有return语句返回非void /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数âintint32_tapache :: thrift :: protocol :: TBinaryProtocolT :: writeI16(int16_t)[与Transport_ = apache :: thrift :: transport :: TTransport]â:/usr/local/include/thrift/protocol/TVirtualProtocol.h:401:instan 来自âint32_tapache :: thrift :: protocol :: TVirtualProtocol :: writeI16_virt(int16_t)[with Protocol_ = apache :: thrift :: protocol :: TBinaryProtocolT,Super_ = apache :: thrift :: protocol :: TProtocolDefaults]âSomething_server. skeleton.cpp:42:从这里实例化/usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147:错误:âthtonsâ未在此范围内声明/usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数âintint32_tapache :: thrift :: protocol :: TBinaryProtocolT :: writeI32(int32_t)[与Transport_ = apache :: thrift :: transport :: TTransport]â:/ usr/local/include/thrift/protocol/TVirtualProtocol. h:405:从âint32_tapache :: thrift :: protocol :: TVirtualProtocol :: writeI32_virt(int32_t)[与Protocol_ = apache :: thrift :: protocol :: TBinaryProtocolT,Super_ = apache :: thrift :: protocol :: TProtocolDefaults实例化]âSomething_server.skeleton.cpp:42:从这里实例化/usr/local/include/thrift/protocol/TBinaryProtocol.tcc:154:错误:âhtonlâ不是dec lared在这个范围/usr/local/include/thrift/protocol/TBinaryProtocol.tcc:在成员函数âintint32_tapache :: thrift :: protocol :: TBinaryProtocolT :: readI16(int16_t&)[与Transport_ = apache :: thrift :: transport :: TTransport]答:

小智.. 5

在我的系统(Ubuntu 10.10)上,htons()和htonl()在netinet/in.h中声明.

我有同样的错误,我通过在构建我的Thrift服务器时将-DHAVE_NETINET_IN_H添加到g ++命令行参数来修复它.

这将导致预处理器在thrift/protocol/TPrototol.h中包含netinet/in.h,因此编译器可以看到hton*声明.

TProtocol.h具有以下行,当未定义HAVE_NETINET_IN_H时,这些行会导致编译器错误.

#ifdef HAVE_NETINET_IN_H
#include 
#endif

这可能是Thrift配置脚本中的一个错误,它以某种方式跳过了定义.



1> 小智..:

在我的系统(Ubuntu 10.10)上,htons()和htonl()在netinet/in.h中声明.

我有同样的错误,我通过在构建我的Thrift服务器时将-DHAVE_NETINET_IN_H添加到g ++命令行参数来修复它.

这将导致预处理器在thrift/protocol/TPrototol.h中包含netinet/in.h,因此编译器可以看到hton*声明.

TProtocol.h具有以下行,当未定义HAVE_NETINET_IN_H时,这些行会导致编译器错误.

#ifdef HAVE_NETINET_IN_H
#include 
#endif

这可能是Thrift配置脚本中的一个错误,它以某种方式跳过了定义.

推荐阅读
路人甲
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有