1

I'm trying to compile a utility in C++ with Visual Studio 2015, which requires the Boost asio library for networking (http requests). The same solution includes a project to build this Boost asio library, but I had to download the boost_1_59_0.7z file. So far, I was able to download it and built was good, but I found the build generated like 11 libs with different names (libboost_chrono-vc140-mt-sgd-1_59.lib, and 10 more but with date_time, filesystem, log-setup, etc...). On the other hand, the project that requires this lib is looking for a library named boost_1_59_0.lib, so my question is how do I know which of the generated libraries is the right one to use for networking (I don't see any name related with asio or networking...). I would appreciate any guidance on this.

Thanks Gus

Gus Sabina
  • 189
  • 1
  • 13

2 Answers2

1

The Boost.Asio doc:

By default, Boost.Asio is a header-only library. However, some developers may prefer to build Boost.Asio using separately compiled source code. To do this, add #include <boost/asio/impl/src.hpp> to one (and only one) source file in a program, then build the program with BOOST_ASIO_SEPARATE_COMPILATION defined in the project/compiler settings. Alternatively, BOOST_ASIO_DYN_LINK may be defined to build a separately-compiled Boost.Asio as part of a shared library.

So, by default Asio is header-file-only and for most uses does not require linking against any Boost library.

But, boost Asio does depens on other boost components likt Boost.System, Boost.Thread(not nessesary) etc. to support better async operations and some error codes ( boost::system::error_code and boost::system::system_error).

see here and here for more info.

Wei Guo
  • 544
  • 3
  • 15
0

boost asio is a header-only library but asio networking depends upon boost system for error messages, which isn't a header only library. In short, your code needs to link to boost-system and it may also require boost-chrono for asio timers.

Note: boost supports autolinking in Visual Studio; so you just need to add the path to the boost library directory to the Library Directories configuration properties, e.g.:

$BOOST_ROOT\stage\lib

Where $BOOST_ROOT is the directory where you installed boost.

You do not need to add boost-system or boost-chrono to Linker->Input->Additional Dependencies. However, you may need to add Windows networking libraries, such as: wsock32 and ws2_32.

kenba
  • 4,303
  • 1
  • 23
  • 40