Boost library is linked, but it shouldn't be [duplicate] - c++

Which Boost libraries are header-only? And which require building libraries?
Does such a list exist?

The list of libraries that require building is here for Unix-like systems, and here for Windows.
For the current release, 1.58, both are the same:
Boost.Chrono
Boost.Context
Boost.Filesystem
Boost.GraphParallel
Boost.IOStreams
Boost.Locale
Boost.MPI
Boost.ProgramOptions
Boost.Python
Boost.Regex
Boost.Serialization
Boost.Signals
Boost.System
Boost.Thread
Boost.Timer
Boost.Wave
A few libraries have optional separately-compiled binaries:
Boost.DateTime
Boost.Graph
Boost.Math
Boost.Random
Boost.Test
Boost.Exception
Note that some libraries may depend on these (for example, Asio depends on System as pointed out in the comments), so you may still need to build something even if the library you want isn't on the list.

Actually, even ./bootstrap.sh --show-libraries is somewhat incorrect too, because some libraries depend on that listed libraries.
It is possible to get list of header-only libraries with the Boost BCP tool, launching the tool on every library and removing those linking any binaries. That is what was done in How To Build Header Only Boost.
For Boost 1.67.0 the resulting list was:
accumulators
align
any
array
assert
assign
bind
callable_traits
circular_buffer
compatibility
concept_check
config
container_hash
conversion
convert
core
crc
detail
disjoint_sets
dynamic_bitset
endian
foreach
format
function
functional
function_types
fusion
geometry
gil
hana
heap
hof
icl
integer
interprocess
intrusive
io
iterator
lambda
lexical_cast
locale
local_function
logic
metaparse
move
mp11
mpl
msm
multi_array
multi_index
optional
phoenix
poly_collection
polygon
predef
preprocessor
property_tree
proto
ptr_container
qvm
ratio
rational
scope_exit
signals2
smart_ptr
sort
static_assert
throw_exception
tokenizer
tti
tuple
type_index
typeof
type_traits
units
unordered
utility
uuid
variant
vmd
winapi
xpressive

I think the list above is not accurate even though it's from the official documentation. See https://svn.boost.org/trac10/ticket/13222
Instead you can query the list of libraries that need to be built:
> ./bootstrap.sh --show-libraries
The Boost libraries requiring separate building and installation are:
atomic
chrono
container
context
coroutine
date_time
exception
fiber
filesystem
graph
graph_parallel
iostreams
locale
log
math
metaparse
mpi
program_options
python
random
regex
serialization
signals
stacktrace
system
test
thread
timer
type_erasure
wave
Note: On Windows you have to call
bootstrap.bat to build "b2" and then call b2 --show-libraries instead.

Related

Boost.Asio without Boost.System

On the Boost System page it is stated that:
The Boost System Library is part of the C++11 Standard Library.
But a number of Boost libraries, such as Asio, depend on Boost System. Is it possible to use the C++11 std stuff instead of Boost System to work with Asio?
AFAIR you can configure Boost System to be header-only
Source: http://www.boost.org/doc/libs/1_66_0/libs/system/doc/reference.html
Other than that, you might simply use Non-Boost Asio

which library should i use in order to compile with boost algorithm

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).

How do people distrubute boost programs which have binary dependencies on boost modules?

I have a very basic client/server project that uses boost::asio. It generates two executables, a client and a server.
When I run the client, I get the following:
./client: error while loading shared libraries:
libboost_system.so.1.55.0: cannot open shared object
file: No such file or directory
This means that the program requires the boost_system binary to be loaded dynamically at run-time. This makes sense, as one dependency of boost_asio is boost_system.
What does this mean for the ease of distributing my application to end-users?
1) Do I simply pop my development version of the boost_system binary on my system, which in this case is libboost_system.so.1.55.0? How do I ensure that when the user runs the client, it will find the dynamic archive? Obviously, on my system, even with my boost install it still didn't find the archive.
2) I am building on Linux and thus I have .so binaries. How will #1 change if I try to cross-compile my app for Windows with mingw-w64?
I am brand-spanking new to distributing C++ programs and working with dynamic/shared libraries.
When I compile statically, I get the following warning:
Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
Suggestion:
1) If you use shared libraries, you'll definitely need to include those libraries your program actually uses alone with your executable.
2) Here is a list of the Boost libraries. Your program will require just a subset:
http://www.boost.org/doc/libs/1_49_0/more/getting_started/unix-variants.html
The only Boost libraries that must be built separately are:
Boost.Filesystem
Boost.GraphParallel
Boost.IOStreams
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.Wave
A few libraries have optional separately-compiled binaries:
Boost.DateTime has a binary component that is only needed if you're using its to_string/from_string or serialization features, or if you're targeting Visual C++ 6.x or Borland.
Boost.Graph also has a binary component that is only needed if you intend to parse GraphViz files. * Boost.Math has binary components for the TR1 and C99 cmath functions.
Boost.Random has a binary component which is only needed if you're using random_device.
Boost.Test can be used in “header-only” or “separately compiled” mode, although separate compilation is recommended for serious use.
Alternatively, you can link your program with static (.a) Boost libraries instead of shared (.so), in which case there will be NO runtime dependencies.
Or you can mix/match shared/statis as you wish.
The choice is yours.
Look at the Boost documentation: b2 Static and Shared libraries
As said, you need to compile boost with the static option, for example
bjam install --toolset=msvc variant=release link=static threading=multi runtime-link=static
You can have more information in this Thread
Do i have static or dynamic boost libraries?
Something to notice, if you do an ldd on your executable, you'll probably notice some runtime dependencies on gcc/libc libraries, even if you compile it in static mode.
That means your client platform has to have those libraries installed. 90% of the time they're there, but it might be more complicated when you compile with the latest version of the compiler and the client has an older one.

Which Boost libraries are header-only?

Which Boost libraries are header-only? And which require building libraries?
Does such a list exist?
The list of libraries that require building is here for Unix-like systems, and here for Windows.
For the current release, 1.58, both are the same:
Boost.Chrono
Boost.Context
Boost.Filesystem
Boost.GraphParallel
Boost.IOStreams
Boost.Locale
Boost.MPI
Boost.ProgramOptions
Boost.Python
Boost.Regex
Boost.Serialization
Boost.Signals
Boost.System
Boost.Thread
Boost.Timer
Boost.Wave
A few libraries have optional separately-compiled binaries:
Boost.DateTime
Boost.Graph
Boost.Math
Boost.Random
Boost.Test
Boost.Exception
Note that some libraries may depend on these (for example, Asio depends on System as pointed out in the comments), so you may still need to build something even if the library you want isn't on the list.
Actually, even ./bootstrap.sh --show-libraries is somewhat incorrect too, because some libraries depend on that listed libraries.
It is possible to get list of header-only libraries with the Boost BCP tool, launching the tool on every library and removing those linking any binaries. That is what was done in How To Build Header Only Boost.
For Boost 1.67.0 the resulting list was:
accumulators
align
any
array
assert
assign
bind
callable_traits
circular_buffer
compatibility
concept_check
config
container_hash
conversion
convert
core
crc
detail
disjoint_sets
dynamic_bitset
endian
foreach
format
function
functional
function_types
fusion
geometry
gil
hana
heap
hof
icl
integer
interprocess
intrusive
io
iterator
lambda
lexical_cast
locale
local_function
logic
metaparse
move
mp11
mpl
msm
multi_array
multi_index
optional
phoenix
poly_collection
polygon
predef
preprocessor
property_tree
proto
ptr_container
qvm
ratio
rational
scope_exit
signals2
smart_ptr
sort
static_assert
throw_exception
tokenizer
tti
tuple
type_index
typeof
type_traits
units
unordered
utility
uuid
variant
vmd
winapi
xpressive
I think the list above is not accurate even though it's from the official documentation. See https://svn.boost.org/trac10/ticket/13222
Instead you can query the list of libraries that need to be built:
> ./bootstrap.sh --show-libraries
The Boost libraries requiring separate building and installation are:
atomic
chrono
container
context
coroutine
date_time
exception
fiber
filesystem
graph
graph_parallel
iostreams
locale
log
math
metaparse
mpi
program_options
python
random
regex
serialization
signals
stacktrace
system
test
thread
timer
type_erasure
wave
Note: On Windows you have to call
bootstrap.bat to build "b2" and then call b2 --show-libraries instead.

How to find out what dependencies (i.e other Boost libraries) a particular Boost library requires?

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).