链接thrift服务器c ++时出错

时间:2012-05-17 13:20:00

标签: c++ thrift

我正在尝试用c ++构建一个thrift服务器,但我似乎遇到了链接阶段的问题。任何人都可以放弃任何光明吗?

这就是我正在运行的。 (原谅我是c ++ n00b):

g++ -Wall -L/usr/local/lib  user_constants.o user_types.o UserService_server.o -lthrift

这是输出

user_types.o: In function `UserCollection::read(apache::thrift::protocol::TProtocol*)':
user_types.cpp:(.text+0xaba): undefined reference to `CollectionInformation::read(apache::thrift::protocol::TProtocol*)'
user_types.o: In function `UserCollection::write(apache::thrift::protocol::TProtocol*) const':
user_types.cpp:(.text+0xca7): undefined reference to `CollectionInformation::write(apache::thrift::protocol::TProtocol*) const'
UserService_server.o: In function `UserServiceProcessor::UserServiceProcessor(boost::shared_ptr<UserServiceIf>)':
UserService_server.cpp:(.text._ZN20UserServiceProcessorC2EN5boost10shared_ptrI13UserServiceIfEE[_ZN20UserServiceProcessorC5EN5boost10shared_ptrI13UserServiceIfEE]+0x33): undefined reference to `vtable for UserServiceProcessor'
UserService_server.cpp:(.text._ZN20UserServiceProcessorC2EN5boost10shared_ptrI13UserServiceIfEE[_ZN20UserServiceProcessorC5EN5boost10shared_ptrI13UserServiceIfEE]+0xaf): undefined reference to `UserServiceProcessor::process_getById(int, apache::thrift::protocol::TProtocol*, apache::thrift::protocol::TProtocol*, void*)'
UserService_server.cpp:(.text._ZN20UserServiceProcessorC2EN5boost10shared_ptrI13UserServiceIfEE[_ZN20UserServiceProcessorC5EN5boost10shared_ptrI13UserServiceIfEE]+0x136): undefined reference to `UserServiceProcessor::process_save(int, apache::thrift::protocol::TProtocol*, apache::thrift::protocol::TProtocol*, void*)'
UserService_server.cpp:(.text._ZN20UserServiceProcessorC2EN5boost10shared_ptrI13UserServiceIfEE[_ZN20UserServiceProcessorC5EN5boost10shared_ptrI13UserServiceIfEE]+0x1bd): undefined reference to `UserServiceProcessor::process_destroy(int, apache::thrift::protocol::TProtocol*, apache::thrift::protocol::TProtocol*, void*)'
UserService_server.cpp:(.text._ZN20UserServiceProcessorC2EN5boost10shared_ptrI13UserServiceIfEE[_ZN20UserServiceProcessorC5EN5boost10shared_ptrI13UserServiceIfEE]+0x23e): undefined reference to `UserServiceProcessor::process_search(int, apache::thrift::protocol::TProtocol*, apache::thrift::protocol::TProtocol*, void*)'
UserService_server.cpp:(.text._ZN20UserServiceProcessorC2EN5boost10shared_ptrI13UserServiceIfEE[_ZN20UserServiceProcessorC5EN5boost10shared_ptrI13UserServiceIfEE]+0x2bc): undefined reference to `UserServiceProcessor::process_searchByName(int, apache::thrift::protocol::TProtocol*, apache::thrift::protocol::TProtocol*, void*)'
UserService_server.cpp:(.text._ZN20UserServiceProcessorC2EN5boost10shared_ptrI13UserServiceIfEE[_ZN20UserServiceProcessorC5EN5boost10shared_ptrI13UserServiceIfEE]+0x33a): undefined reference to `UserServiceProcessor::process_searchByEmailAddress(int, apache::thrift::protocol::TProtocol*, apache::thrift::protocol::TProtocol*, void*)'
UserService_server.cpp:(.text._ZN20UserServiceProcessorC2EN5boost10shared_ptrI13UserServiceIfEE[_ZN20UserServiceProcessorC5EN5boost10shared_ptrI13UserServiceIfEE]+0x3b8): undefined reference to `UserServiceProcessor::process_checkUsernameExists(int, apache::thrift::protocol::TProtocol*, apache::thrift::protocol::TProtocol*, void*)'
UserService_server.cpp:(.text._ZN20UserServiceProcessorC2EN5boost10shared_ptrI13UserServiceIfEE[_ZN20UserServiceProcessorC5EN5boost10shared_ptrI13UserServiceIfEE]+0x436): undefined reference to `UserServiceProcessor::process_registerUser(int, apache::thrift::protocol::TProtocol*, apache::thrift::protocol::TProtocol*, void*)'
UserService_server.cpp:(.text._ZN20UserServiceProcessorC2EN5boost10shared_ptrI13UserServiceIfEE[_ZN20UserServiceProcessorC5EN5boost10shared_ptrI13UserServiceIfEE]+0x4b4): undefined reference to `UserServiceProcessor::process_verifyUser(int, apache::thrift::protocol::TProtocol*, apache::thrift::protocol::TProtocol*, void*)'
UserService_server.o: In function `apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::writeMessageBegin(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, apache::thrift::protocol::TMessageType, int)':
UserService_server.cpp:(.text._ZN6apache6thrift8protocol16TBinaryProtocolTINS0_9transport10TTransportEE17writeMessageBeginERKSsNS1_12TMessageTypeEi[apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::writeMessageBegin(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, apache::thrift::protocol::TMessageType, int)]+0x27): undefined reference to `apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::VERSION_1'
UserService_server.o: In function `apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::readMessageBegin(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, apache::thrift::protocol::TMessageType&, int&)':
UserService_server.cpp:(.text._ZN6apache6thrift8protocol16TBinaryProtocolTINS0_9transport10TTransportEE16readMessageBeginERSsRNS1_12TMessageTypeERi[apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::readMessageBegin(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, apache::thrift::protocol::TMessageType&, int&)]+0x48): undefined reference to `apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::VERSION_MASK'
UserService_server.cpp:(.text._ZN6apache6thrift8protocol16TBinaryProtocolTINS0_9transport10TTransportEE16readMessageBeginERSsRNS1_12TMessageTypeERi[apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::readMessageBegin(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, apache::thrift::protocol::TMessageType&, int&)]+0x53): undefined reference to `apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::VERSION_1'
collect2: ld returned 1 exit status

2 个答案:

答案 0 :(得分:2)

你的构建线看起来有点“瘦”。您确定使用-L使用-l以及库本身使用LD_LIBRARY_PATH来获取库的所有位置吗?

综观以上所述,我认为Boost和Apache是​​罪魁祸首。你必须单独链接它们吗?另外,记住一些体系结构,预计库路径变量(通常为{{1}})需要在链接时以及运行时设置为构建命令行上的路径。

答案 1 :(得分:0)

通常的thrift为每个接口生成三个.cpp文件(* .thrift)你应该将所有这些文件(UserService.cpp和UserService_constants.cpp,UserService_types.cpp)添加到g ++参数。