V
V
Valerij_liquid2014-05-14 23:02:07
C++ / C#
Valerij_liquid, 2014-05-14 23:02:07

How to combine libtorrent and boost libraries?

Good day, I am writing an application using libtorrent (it works using the boost library).
I am working in Visual Studio 2012. Libtorrent is compiled for static linking to the project with the following parameters: toolset=msvc-11.0 boost-link=static boost=system geoip=off encryption=tommath link=static variant=debug runtime-link=static .
I'm interested in using the Boost::asio library. When I try to simply include the header file ( #include ), I get a linker error about redefining symbols (because they are already included in libtorrent ). In general, after much digging, I got the linker to swear that it cannot recognize characters in those Boost library functions that I use:

1>     Creating library G:\CPP\Torrent\tDownloader\Debug\tDownloader.lib and object G:\CPP\Torrent\tDownloader\Debug\tDownloader.exp
1>tDownloaderDlg.obj : error LNK2001: unresolved external symbol "class boost::system::error_code __cdecl boost::asio::detail::socket_ops::getaddrinfo(char const *,char const *,struct addrinfo const &,struct addrinfo * *,class boost::system::error_code &)" ([email protected][email protected]@[email protected]@@[email protected]@[email protected]@@[email protected]@@Z)
1>tDownloaderDlg.obj : error LNK2001: unresolved external symbol "void __cdecl boost::asio::detail::socket_ops::freeaddrinfo(struct addrinfo *)" ([email protected][email protected]@[email protected]@@[email protected]@@Z)

When compiling, I use the following keys:
/Yu"stdafx.h" /MP /GS /analyze- /W3 /Zc:wchar_t /I"G:\CPP\LIBS\UNRAR\Dll" /I"D:\boost" /I"G:\CPP\Torrent\include" /ZI /Gm /Od /sdl /Fd"Debug\vc110.pdb" /fp:precise /D "_USING_V110_SDK71_" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /MTd /Fa"Debug\" /EHsc /nologo /Fo"Debug\" /Fp"Debug\tDownloader.pch"

And when linking:
/OUT:"G:\CPP\Torrent\tDownloader\Debug\tDownloader.exe" /MANIFEST /NXCOMPAT /PDB:"G:\CPP\Torrent\tDownloader\Debug\tDownloader.pdb" /DYNAMICBASE "libtorrent.lib" /DEBUG /LTCG:STATUS /MACHINE:X86 /INCREMENTAL:NO /PGD:"G:\CPP\Torrent\tDownloader\Debug\tDownloader.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Debug\tDownloader.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"D:\boost\bin.v2\libs" /LIBPATH:"D:\boost\bin.v2"  /LIBPATH:"G:\CPP\Torrent\bin\msvc-11.0\debug\boost-source\link-static\runtime-link-static\threading-multi" /TLBID:1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
code-dreamer, 2014-06-17
@code-dreamer

These functions are defined in boost\asio\detail\impl\socket_ops.ipp. To include them in the boost build, you need to define _WIN32_WINNT >= 0x0501, for example:
bjam define=_WIN32_WINNT=0x0501 ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question