Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2010 Unresolved External Symbol boost::asio::detail::winsock_init_base::throw_on_error when linking boost-system with a project using libtorrent

I'm trying to build a small command line BitTorrent client using Rasterbar's libtorrent, which depends on Boost. I've built both the Boost libraries and the libtorrent library using their respective directions, but when I try to build my project I get the following linking errors

1>------ Build started: Project: MiniBT, Configuration: Debug Win32 ------
1>MiniBT.obj : error LNK2019: unresolved external symbol "protected: static void __cdecl boost::asio::detail::winsock_init_base::throw_on_error(struct boost::asio::detail::winsock_init_base::data &)" (?throw_on_error@winsock_init_base@detail@asio@boost@@KAXAAUdata@1234@@Z) referenced in function "public: __thiscall boost::asio::detail::winsock_init<2,0>::winsock_init<2,0>(bool)" (??0?$winsock_init@$01$0A@@detail@asio@boost@@QAE@_N@Z)
1>MiniBT.obj : error LNK2019: unresolved external symbol "protected: static void __cdecl boost::asio::detail::winsock_init_base::startup(struct boost::asio::detail::winsock_init_base::data &,unsigned char,unsigned char)" (?startup@winsock_init_base@detail@asio@boost@@KAXAAUdata@1234@EE@Z) referenced in function "public: __thiscall boost::asio::detail::winsock_init<2,0>::winsock_init<2,0>(bool)" (??0?$winsock_init@$01$0A@@detail@asio@boost@@QAE@_N@Z)
1>MiniBT.obj : error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::asio::error::get_misc_category(void)" (?get_misc_category@error@asio@boost@@YAABVerror_category@system@3@XZ) referenced in function "void __cdecl boost::asio::error::`dynamic initializer for 'misc_category''(void)" (??__Emisc_category@error@asio@boost@@YAXXZ)
1>MiniBT.obj : error LNK2019: unresolved external symbol "unsigned long __cdecl boost::asio::detail::win_tss_ptr_create(void)" (?win_tss_ptr_create@detail@asio@boost@@YAKXZ) referenced in function "public: __thiscall boost::asio::detail::win_tss_ptr<class boost::asio::detail::call_stack<class boost::asio::detail::win_iocp_io_service,unsigned char>::context>::win_tss_ptr<class boost::asio::detail::call_stack<class boost::asio::detail::win_iocp_io_service,unsigned char>::context>(void)" (??0?$win_tss_ptr@Vcontext@?$call_stack@Vwin_iocp_io_service@detail@asio@boost@@E@detail@asio@boost@@@detail@asio@boost@@QAE@XZ)
1>MiniBT.obj : error LNK2019: unresolved external symbol "protected: static void __cdecl boost::asio::detail::winsock_init_base::cleanup(struct boost::asio::detail::winsock_init_base::data &)" (?cleanup@winsock_init_base@detail@asio@boost@@KAXAAUdata@1234@@Z) referenced in function "public: __thiscall boost::asio::detail::winsock_init<2,0>::~winsock_init<2,0>(void)" (??1?$winsock_init@$01$0A@@detail@asio@boost@@QAE@XZ)

It seems to indicate that the asio::detail namespace didn't get included in the boost-system library as it is only those 5 symbols that it seems to have a problem with and it is linking to the boost-system library just fine otherwise. I'm trying to build a 32-bit application on a 64-bit system, but everything I've checked seems to be correctly configured for this.

I know I'm missing something, but I can't seem to figure out what. Does anyone have any suggestions?

like image 540
Richard McDaniel Avatar asked Oct 07 '22 08:10

Richard McDaniel


1 Answers

With BOOST_ASIO_SEPARATE_COMPILATION defined, in addition to #include "boost/asio/ssl/impl/src.hpp", you must also #include "boost/asio/impl/src.hpp" in one of your cpp files.

like image 128
Erik Hvatum Avatar answered Oct 13 '22 12:10

Erik Hvatum