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 options when creating my Thrift server.
This will cause the preprocessor to include netinet / in.h in thrift / protocol / TPrototol.h, so hton * declarations will be visible to the compiler.
TProtocol.h has the following lines that cause a compiler error when HAVE_NETINET_IN_H is not defined.
#ifdef HAVE_NETINET_IN_H #include <netinet/in.h> #endif
This might be a bug in the Thrift configure script that somehow skips the definition.
source share