Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2005-08-06 05:20:43

>I was really shocked when a bcp shared_ptr foo/ copied 274 files. I
> expected a lot, but not that many. Then I read the doc's more closely
> and it says that if you depend on any header from a lib, you get the
> whole lib. Could it be possible to add a -minimal option to have only
> the actual headers used included?

No you don't get the whole library if you include just one header, what you
do get:

* It searches for library names first, so using "regex" as a name will give
you everything in the libs/regex directory and everything that depends on,
but that's not the case here.
* If you include the header of a library with separate source, then you get
that libraries source and all it's dependencies, but that's not the case
* When you include a header, bcp doesn't know what compiler you're using, so
it follows all possible preprocessor paths. If you're distributing a subset
of Boost with you're application then that is what you want to have happen
in general. This is the case here, and it does bloat things, but not by as
much as you think:


g++ -x c++ -E -I. boost/shared_ptr.hpp | grep -c 'boost/'

Gives an answer of 83, so that's the smallest number of headers you could
have got away with for that one compiler, then running bcp in report mode,
we can see what all the "extra" headers are:

* All of the config system *headers* (52 headers, would be about 6 for one
compiler only).
* All of the shared pointer synchronisation code (24 headers, would be about
4 for one compiler/platform).
* A lot of MPL and type traits code that includes workarounds for broken
compilers that you may or may not need (in fact gcc appears not include any
of these headers at all).
* A lot of preprocessor lib headers, that are only really needed for type
traits and MPL maintenance, some of these could be trimmed out, but it's not
clear how many: MPL in particular cannot be used at all without the
preprocessor lib.

To conclude: the only "minimal" version would be to extract the headers used
by a *specific compiler*, but you can already do that by preprocessing the
header and grepping for the filenames to copy.


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at