how I use only the Asio of Boost Library without adding any other library? Is that possible?
In the Boost, don't have the folder called "lib" with the *.a files?
Asio exists as as standalone library, entirely independent of Boost (this is the "original").
No need to search together the bits from Boost subdirectories if you don't want to use Boost, just download Asio and use that. :-)
Since Asio is a header-only library, there are no lib files associated with it. You can extract only the absolutly needed header files with bcp, which is included.
Related
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
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.
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.
I am using a self compiled boost library, have to add libraries for compiling, but I can't tell which boost library should I add in order to use Boost::Algorithm, There is not a clear named library file for it like 'libboost_regex' for "regex" and 'libboost_thread' for "thread".
Only a small number of boost libraries must be built and linked against your application. The list is on their Getting Started page. Here it is:
Boost.Chrono
Boost.Context
Boost.Filesystem
Boost.GraphParallel
Boost.IOStreams
Boost.Locale
Boost.MPI
Boost.ProgramOptions
Boost.Python (see the Boost.Python build documentation before building and installing it)
Boost.Regex
Boost.Serialization
Boost.Signals
Boost.System
Boost.Thread
Boost.Timer
Boost.Wave
As you can see, Boost.Algorithm is not on there. In order to use it, you need only include the header file(s).
For any C++ Boost library, how can one find out which Boost library(ies) it requires ?
Example (not necessary a working example though): Boost library "test" requires Boost library "date_time".
Regards,
boost comes with a tool to gather the dependencies of a library.
It is called bcp. If you just want a list of files, you have to use the --list option.
If you want to find out those dependencies to isolate the components your software requires, you can use bcp (Boost Copy)
It copies selected boost libraries and all its dependencies to a target location.
Eg
bcp regex /foo
copies the complete regex library and its dependencies to /foo
Disclaimer: I do not have any practical experience with bcp.
EDIT:
If you only want to check on which compiled library a compiled library depends, you can either use ldd <boost_library_filename>.so on Linux or Dependency Walker on Windows.
A modern solution is to use boost
Dependency Report (available starting from boost v1.66.0).
I am using the Boost headers in my project which is compiled by g++. I downloaded the Boost source and didn't build it so there are no library files to link.
When I read the Boost website (http://www.boost.org/doc/libs/1_40_0/) it says Boost.Thread requires its corresponding library, but I am happily using the <boost/thread/mutex.hpp>(boost::mutex) header without linking to the Boost thread library.
How do I really tell whether I need to link the corresponding library for using a particular Boost header file or not?
In a Terminal:
./bootstrap.sh --show-libraries
The output shows the list of libraries requiring special build and installation.
The Boost documentation states whether a given library is header only or not. If you're using a library which isn't specified header only, and are not linking against the corresponding library, it's undefined behavior.
The fact that it happens to work (or seems to work) isn't really relevant.
I want to use Boost core libraries (like lambda) and Boost ASIO library in a large cross-platform project built with the Cmake. I want to put Boost & ASIO in my source control tree and build it as part of project with the Cmake. So I don't want to "install" it on computers and link with it.
How can this be done? Does there exist CMakeLists.txt for Boost?
Both Boost.Lambda and Boost.ASIO are header-only libraries, so in your CMakeLists.txt file, you could include your Boost include directory in the INCLUDE_DIRECTORIES variable, and when your code is built, the header code will be built into your resulting modules.
For situations where you are using non-header-only libraries, like Boost.Filesystem, then you will have to either ship libraries you built, or modify the experimental CMake version of boost.build, which you can find here: https://svn.boost.org/trac/boost/wiki/CMake
Edit
I was slightly confused about Boost.Asio. It is not truly header-only, because it depends on Boost.System, and possibly Boost.Thread depending on how you use it.
However, Boost.Asio is derived from Asio ( http://think-async.com/ ), which is header-only.
There is a project aiming at providing a CMake version of boost. It is quite outdated, but the CMakeLists.txt might help you. You can check it out there.