使用 Thrift C++ Xcode 中的库
我想在 Xcode 中使用 Thrift 0.8.0 c++ 库。因此,我配置了 thrift,
./configure --without-java --without-python --without-ruby --without-php --enable-static
并将静态库拖到我的项目中。然后我将“标头搜索路径”设置为“/usr/local/include/thrift”和“/opt/local/include”(因为我通过 macports 安装了 boost)。
我可以按照此处所述运行Thrift服务器,
当我尝试运行客户端时,它会抛出几个错误。
/usr/local/include/thrift/transport/TSocket.h
sockaddr* getCachedAddress(socklen_t* len) const;
/usr/local/include/thrift/transport/TSocket.h:216:3:错误:未知类型名称“sockaddr”
void setCachedAddress(const sockaddr* addr, socklen_t len);
/usr/local/include/thrift/ Transport/TSocket.h:216:30: 错误:未知类型名称“socklen_t”
void setCachedAddress(const sockaddr* addr, socklen_t len);
/usr/local/include/thrift/transport/TSocket.h:237:31: 错误: 未知类型名称 'sockaddr'
void setCachedAddress(const sockaddr* addr, socklen_t len);
/usr/local/include/thrift/transport/TSocket.h:237:47: 错误: 未知类型名称“socklen_t”
/usr/local/include/thrift/transport/TSocket.h:290:5:错误:未知类型名称“sockaddr_in”
union {
sockaddr_in ipv4;
sockaddr_in6 ipv6;
} cachedPeerAddr_;
/usr/local/include/thrift/transport/TSocket.h:291:5:错误:未知类型名称“sockaddr_in6”
boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
.../ThriftClient/ThriftClient/Something_client.cpp .../ThriftClient/ThriftClient/Something_client.cpp:15:49:{15:68-15:74}:错误:没有匹配的构造函数用于初始化“apache::thrift::transport::TBufferedTransport”[3]
可以有人帮助我吗?谢谢你!
更新
在 TSocket.h 中包含以下几行后,一切正常。
#include <sys/socket.h>
#include <arpa/inet.h>
I want to use the Thrift 0.8.0 c++ library in Xcode. Therefore I configured thrift with
./configure --without-java --without-python --without-ruby --without-php --enable-static
I dragged the static library into my project. Then I set the "Header Search Paths" to "/usr/local/include/thrift" and "/opt/local/include" (because i installed boost with via macports).
I can run the Thrift Server as described here
When I try to run the client it throws several errors.
/usr/local/include/thrift/transport/TSocket.h
sockaddr* getCachedAddress(socklen_t* len) const;
/usr/local/include/thrift/transport/TSocket.h:216:3: error: unknown type name 'sockaddr'
void setCachedAddress(const sockaddr* addr, socklen_t len);
/usr/local/include/thrift/transport/TSocket.h:216:30: error: unknown type name 'socklen_t'
void setCachedAddress(const sockaddr* addr, socklen_t len);
/usr/local/include/thrift/transport/TSocket.h:237:31: error: unknown type name 'sockaddr'
void setCachedAddress(const sockaddr* addr, socklen_t len);
/usr/local/include/thrift/transport/TSocket.h:237:47: error: unknown type name 'socklen_t'
/usr/local/include/thrift/transport/TSocket.h:290:5: error: unknown type name 'sockaddr_in'
union {
sockaddr_in ipv4;
sockaddr_in6 ipv6;
} cachedPeerAddr_;
/usr/local/include/thrift/transport/TSocket.h:291:5: error: unknown type name 'sockaddr_in6'
boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
.../ThriftClient/ThriftClient/Something_client.cpp
.../ThriftClient/ThriftClient/Something_client.cpp:15:49:{15:68-15:74}: error: no matching constructor for initialization of 'apache::thrift::transport::TBufferedTransport' [3]
Can anyone help me? Thank you!
UPDATE
After including in TSocket.h the following lines everything works fine.
#include <sys/socket.h>
#include <arpa/inet.h>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
或者只是
or just