简体   繁体   中英

Using Thrift C++ Library in Xcode

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>
#include <thrift/config.h> 

要不就

#define HAVE_CONFIG_H 1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM