Re: [libtorrent] Building simple_client example
Brought to you by:
arvidn
From: arvid <ar...@cs...> - 2014-10-10 16:20:54
|
On 2014-10-10 05:20, Bedeho Mender wrote: > I am trying to build a reduced version of the simple_client example > > #define WIN32 1 > #define BOOST_ASIO_SEPARATE_COMPILATION 1 > #define TORRENT_USE_IPV6 1 > #define NDEBUG 1 > #define TORRENT_NO_DEPRECATE 1 > #define TORRENT_DISABLE_GEO_IP 1 most of these only affect libtorrent itself. Some of them also affect the ABI of the library (specifically TORRENT_NO_DEPRECATE). By just defining these when including the libtorrent headers, you're effectively causing your application to treat libtorrent as if it has a different ABI than it was built with. Don't define these build configuration option in one translation unit like this. Define them for the entire project (or at least all of libtorrent and any file including a libtorrent header). With boost-build this is simple, because it allows for propagating build options and requirements. On unix systems it's common to use pkg-config to query what build and link options a package needs, which also solves this problem. > #include <stdlib.h> > #include <libtorrent/entry.hpp> > #include <libtorrent/bencode.hpp> > #include <libtorrent/session.hpp> > > int main(int argc, char* argv[]) > { > return 0; > } > > The configuration options are the same as those used during building, > however, when compiling with msvc10, I get linker errors > > 1>main.obj : error LNK2001: unresolved external symbol "unsigned long > __cdecl boost::asio::detail::win_tss_ptr_create(void)" > (?win_tss_ptr_create@detail@asio@boost@@YAKXZ) > 1>main.obj : error LNK2001: 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) > 1>main.obj : error LNK2001: 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) > 1>main.obj : error LNK2001: 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) > 1>main.obj : error LNK2001: 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) > > It seems that linking with various boost::asio functions does not work. it looks like you're not linking against wsock32 nor libboost_system. The asio functions are probably missing because you probably did not define BOOST_ASIO_SEPARATE_COMPILATION when building libotrrent, so it used asio as headers only. > Building a general boost::asio example works, like this one > http://www.boost.org/doc/libs/1_56_0/doc/html/boost_asio/tutorial/tutdaytime1/src.html I bet if you try to build that example and define BOOST_ASIO_SEPARATE_COMPILATION it would also break (without linking against additional asio files). -- Arvid Norberg |