任何人都可以解释我在链接预构建的静态库libsioclient.a时遇到的以下错误。 在调试构建(OPT = 0)的情况下,链接工作正常,但在OPT = 1
时失败*./src/socketio/libsioclient.a(sio_socket.cpp.o): In function `sio::socket:
:impl::emit(std::string const&, sio::message::list const&,
std::function<void (sio::message::list const&)> const&)':
sio_socket.cpp:(.text+0x2822): undefined reference to `vtable for
std::_Sp_counted_ptr<sio::string_message*, (__gnu_cxx::_Lock_policy)2>'
./src/socketio/libsioclient.a(sio_packet.cpp.o): In function
`sio::from_json(rapidjson::GenericValue<rapidjson::UTF8<char>,
rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> > const&,
std::vector<std::shared_ptr<std::string const>,
std::allocator<std::shared_ptr<std::string const> > > const&)':
sio_packet.cpp:(.text+0x2e34): undefined reference to `vtable for
std::_Sp_counted_ptr<sio::string_message*, (__gnu_cxx::_Lock_policy)2>'
sio_packet.cpp:(.text+0x3300): undefined reference to `vtable for
std::_Sp_counted_ptr<sio::object_message*, (__gnu_cxx::_Lock_policy)2>'
collect2: error: ld returned 1 exit status*
这里提到的类,即string_message和object_message都来自同一个虚拟类消息。 虽然还有许多其他类派生自消息,但链接器仅为这两个类提供错误。或者,当此错误得到修复时,可能会出现其他错误。
关于如何对这个链接器错误进行分类的任何线索都会有很大的帮助。