2011-12-06 22 views
4

私はThriftを初めて使用しています:http://thrift.apache.org/ 私はCentOSを使用していて、恐らくThriftをインストールしています。私は倹約を使ってコードを生成することができます。 しかし、指示に従います:http://wiki.apache.org/thrift/ThriftUsageC%2B%2B Something_server.cppをコンパイル中にエラーが発生しました。 理由を知るためにplsが助けてくれることを知っています。何も思いつきません。ありがとうございましたThriftサーバのコンパイル中にエラーが発生しました

私はPHPを使ってC++を呼び出すためにC++だけができる仕事をするようにしました。 誰かが私のために別の提案をしていますか?ありがとう、あなたが不足しているhtons()、htonl()関数に問題があるかのように

[[email protected] gen-cpp]# g++ -Wall -I/usr/local/include/thrift *.cpp -lthrift -o something /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI16(int16_t)â: /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147: error: there are no arguments to âhtonsâ that depend on a template parameter, so a declaration of âhtonsâ must be available /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147: error: (if you use â-fpermissiveâ, G++ will accept your code, but allowing the use of an undeclared name is deprecated) /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI32(int32_t)â: /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:154: error: there are no arguments to âhtonlâ that depend on a template parameter, so a declaration of âhtonlâ must be available Something_server.cpp: In member function âvirtual int32_t SomethingHandler::ping()â: Something_server.cpp:28: warning: no return statement in function returning non-void /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI16(int16_t) [with Transport_ = apache::thrift::transport::TTransport]â: /usr/local/include/thrift/protocol/TVirtualProtocol.h:401: instantiated from âuint32_t apache::thrift::protocol::TVirtualProtocol::writeI16_virt(int16_t) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT, Super_ = apache::thrift::protocol::TProtocolDefaults]â Something_server.cpp:42: instantiated from here /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147: error: âhtonsâ was not declared in this scope /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI32(int32_t) [with Transport_ = apache::thrift::transport::TTransport]â: /usr/local/include/thrift/protocol/TVirtualProtocol.h:405: instantiated from âuint32_t apache::thrift::protocol::TVirtualProtocol::writeI32_virt(int32_t) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT, Super_ = apache::thrift::protocol::TProtocolDefaults]â Something_server.cpp:42: instantiated from here /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:154: error: âhtonlâ was not declared in this scope /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::readI16(int16_t&) [with Transport_ = apache::thrift::transport::TTransport]â: /usr/local/include/thrift/protocol/TVirtualProtocol.h:499: instantiated from âuint32_t apache::thrift::protocol::TVirtualProtocol::readI16_virt(int16_t&) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT, Super_ = apache::thrift::protocol::TProtocolDefaults]â Something_server.cpp:42: instantiated from here /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:362: error: ântohsâ was not declared in this scope /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::readI32(int32_t&) [with Transport_ = apache::thrift::transport::TTransport]â: /usr/local/include/thrift/protocol/TVirtualProtocol.h:503: instantiated from âuint32_t apache::thrift::protocol::TVirtualProtocol::readI32_virt(int32_t&) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT, Super_ = apache::thrift::protocol::TProtocolDefaults]â Something_server.cpp:42: instantiated from here /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:373: error: ântohlâ was not declared in this scope /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI16(int16_t)â: /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147: error: there are no arguments to âhtonsâ that depend on a template parameter, so a declaration of âhtonsâ must be available /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147: error: (if you use â-fpermissiveâ, G++ will accept your code, but allowing the use of an undeclared name is deprecated) /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI32(int32_t)â: /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:154: error: there are no arguments to âhtonlâ that depend on a template parameter, so a declaration of âhtonlâ must be available Something_server.skeleton.cpp: In member function âvirtual int32_t SomethingHandler::ping()â: Something_server.skeleton.cpp:28: warning: no return statement in function returning non-void /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI16(int16_t) [with Transport_ = apache::thrift::transport::TTransport]â: /usr/local/include/thrift/protocol/TVirtualProtocol.h:401: instantiated from âuint32_t apache::thrift::protocol::TVirtualProtocol::writeI16_virt(int16_t) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT, Super_ = apache::thrift::protocol::TProtocolDefaults]â Something_server.skeleton.cpp:42: instantiated from here /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:147: error: âhtonsâ was not declared in this scope /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::writeI32(int32_t) [with Transport_ = apache::thrift::transport::TTransport]â: /usr/local/include/thrift/protocol/TVirtualProtocol.h:405: instantiated from âuint32_t apache::thrift::protocol::TVirtualProtocol::writeI32_virt(int32_t) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT, Super_ = apache::thrift::protocol::TProtocolDefaults]â Something_server.skeleton.cpp:42: instantiated from here /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:154: error: âhtonlâ was not declared in this scope /usr/local/include/thrift/protocol/TBinaryProtocol.tcc: In member function âuint32_t apache::thrift::protocol::TBinaryProtocolT::readI16(int16_t&) [with Transport_ = apache::thrift::transport::TTransport]â:

+0

私は同じボートにあります - CentOS、Thrift build from source – selvin

答えて

2

はそう、あなたは正しいヘッダーが含まれていますか?私のシステムで

#include <arpa/inet.h>

+0

ありがとう、私はこれを試してみましょう。 –

5

(Ubuntuの10.10)、htons()とhtonl()はnetinetの/ in.hで宣言されています。

私は同じエラーがありました。私は、Thriftサーバを構築するときに、g ++のコマンドラインパラメータに-DHAVE_NETINET_IN_Hを追加することで修正しました。

これはプリプロセッサにthrift/protocol/TPrototol.hにnetinet/in.hを含めるので、hton *宣言はコンパイラに見えるようになります。

TProtocol.hには、HAVE_NETINET_IN_Hが定義されていないと、コンパイラエラーの原因となる次の行があります。

#ifdef HAVE_NETINET_IN_H 
#include <netinet/in.h> 
#endif 

これは、何らかの理由で定義をスキップするThrift設定スクリプトのバグかもしれません。

+0

私のために働いた! os:Centos5 x64 – gibffe

1

Gmaneからは、#defineがいくつか必要です。 -DHAVE_INTTYPES_H -DHAVE_NETINET_IN_HをMakefileに追加してください。

例:メイクファイルの中で

BOOST_DIR = /usr/include/boost 
THRIFT_DIR = /usr/local/include/thrift 
LIB_DIR = /usr/local/lib 
BOOST_LIB_DIR = /usr/lib64/boost 
THRIFT_LIB_DIR = /home/timothy.ohare/bin/lib 

g++ -DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H -o CppServer -I${THRIFT_DIR} -I${BOOST_DIR} -I../gen-cpp -L${LIB_DIR} -L${BOOST_LIB_DIR} -L${THRIFT_LIB_DIR} -lthrift CppServer.cpp ${GEN_SRC} 
関連する問題