我正在尝试使用 boost 从 linux 交叉编译到 windows。我已经交叉编译了 boost 并且我有 DLL,但是当我链接时,我得到了几个 undefined reference :
src/client/CommunicationHandler.o:CommunicationHandler.cpp:(.text+0x170): undefined reference to `boost::asio::io_service::io_service()'
src/client/CommunicationHandler.o:CommunicationHandler.cpp:(.text+0x1b7): undefined reference to boost::asio::ip::address_v4::from_string(std::__cxx11::basic_string, std::allocator > const&)'
src/client/CommunicationHandler.o:CommunicationHandler.cpp:(.text+0x1c7): undefined reference to boost::asio::ip::address::address(boost::asio::ip::address_v4 const&)'
src/client/CommunicationHandler.o:CommunicationHandler.cpp:(.text+0x54e): undefined reference to `boost::asio::io_service::~io_service()'
src/client/CommunicationHandler.o:CommunicationHandler.cpp:(.text+0x5c0): undefined reference to `boost::asio::io_service::~io_service()'
src/client/CommunicationHandler.o:CommunicationHandler.cpp:(.text+0x97e): undefined reference to `boost::asio::io_service::run()'
src/client/CommunicationHandler.o:CommunicationHandler.cpp:(.text$_ZN5boost4asio2ip14basic_endpointINS1_3tcpEEC1ERKNS1_7addressEt[_ZN5boost4asio2ip14basic_endpointINS1_3tcpEEC1ERKNS1_7addressEt]+0x2a): undefined reference to boost::asio::ip::detail::endpoint::endpoint(boost::asio::ip::address const&, unsigned short)'
src/client/CommunicationHandler.o:CommunicationHandler.cpp:(.text$_ZN5boost4asio2ip16resolver_serviceINS1_3tcpEE7destroyERSt10shared_ptrIvE[_ZN5boost4asio2ip16resolver_serviceINS1_3tcpEE7destroyERSt10shared_ptrIvE]+0x20): undefined reference to boost::asio::detail::resolver_service_base::destroy(std::shared_ptr&)'
...等等
为什么符号不在 DLL 中?我应该怎么做才能使其正确链接?
最佳答案
这使它有效
#ifndef BOOST_SYSTEM_USE_LIB # 定义 BOOST_SYSTEM_USE_LIB #endif
关于c++ - Boost undefined references交叉编译linux到windows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40557739/