使用 Thrift C++ Xcode 中的库

发布于 2024-12-29 06:17:34 字数 1880 浏览 1 评论 0原文

我想在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

电影里的梦 2025-01-05 06:17:34
#include <thrift/config.h> 

或者只是

#define HAVE_CONFIG_H 1
#include <thrift/config.h> 

or just

#define HAVE_CONFIG_H 1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文