Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2006-02-18 11:29:58


> Is this correct? Am I using bcp correctly? Are there some paths that
> bcp is taking that aren't really neccessary? Can I narrow this huge
> vat of files down to the ones that I *really* need, or is this it?
> How?

I updated the docs recently because of this very case:

"File dependencies are found as follows:

* C++ source files are scanned for #includes, all #includes present in the
boost source tree will then be scanned for their dependencies and so on.
* C++ source files are associated with the name of a library, if that
library has source code (and possibly build data), then include that source
in the dependencies.
* C++ source files are checked for dependencies on Boost.test (for example
to see if they use cpp_main as an entry point).
* HTML files are scanned for immediate dependencies (images and style
sheets, but not links).

It should be noted that in practice bcp can produce a rather "fat" list of
dependencies, reasons for this include:

* 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.
This can be a long list as all the regex test and example programs will get
scanned for their dependencies. If you want a more minimal list, then try
using the names of the headers you are actually including, or use the --scan
option to scan your source code.
* If you include the header of a library with separate source, then you get
that libraries source and all it's dependencies. This is deliberate and in
general those extra dependencies are needed.
* 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.

The last point above can result in a substantial increase in the number of
headers found compared to most peoples expectations. For example bcp finds
274 header dependencies for boost/shared_ptr.hpp: by running bcp in report
mode we can see why all these headers have been found as dependencies:

* All of the Config library headers get included (52 headers, would be about
6 for one compiler only).
* A lot of MPL and type traits code that includes workarounds for broken
compilers that you may or may not need. Tracing back through the code shows
that most of these aren't needed unless the user has defined
BOOST_SP_USE_QUICK_ALLOCATOR, however bcp isn't aware of whether that
preprocessor path will be taken or not, so the headers get included just in
case. This adds about 48 headers (type traits), plus another 49 from MPL.
* The Preprocessor library gets used heavily by MPL: this adds another 96
headers.
* The Shared Pointer library contains a lot of platform specific code, split
up into around 22 headers: normally your compiler would need only a couple
of these files.

As you can see the number of dependencies found are much larger than those
used by any single compiler, however if you want to distribute a subset of
Boost that's usable in any configuration, by any compiler, on any platform
then that's exactly what you need. If you want to figure out which Boost
headers are being used by your specific compiler then the best way to find
out is to prepocess the code and scan the output for boost header includes.
You should be aware that the result will be very platform and compiler
specific, and may not contain all the headers needed if you so much as
change a compiler switch (for example turn on threading support)."

So... to answer your specific question: if you want your code to be portable
to *any* compiler then yes you need all those headers, otherwise using sed
to process the preprocessed source would give you a more slimline set of
headers.

HTH, John


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net