gpt4 book ai didi

c++ - 链接旧服务器 c++ 时出错

转载 作者:行者123 更新时间:2023-11-30 04:27:47 25 4
gpt4 key购买 nike

我正在尝试用 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

最佳答案

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

综上所述,我认为 Boost 和 Apache 是罪魁祸首。你必须单独链接它们吗?此外,请记住,与某些架构相比,库路径变量(通常是 LD_LIBRARY_PATH)也需要在链接时设置为构建命令行上的路径作为运行时。

关于c++ - 链接旧服务器 c++ 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10636536/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com