Boost logo

Boost-Build :

Subject: Re: [Boost-build] Library in sources or requirements?
From: Vladimir Prus (vladimir_at_[hidden])
Date: 2009-06-11 12:16:06

Anthony Foglia wrote:

> When compiling an executable that uses a library, is there a difference
> between:
> exe filesystem-test
> : filesystem_test.cpp
> /boost//filesystem
> ;
> and
> exe filesystem-test
> : filesystem_test.cpp
> : <library>/boost//filesystem
> ;
> We've been using the former, and that's what's described more
> prominently in the documentation, but the contrib/boost.jam file uses
> the other one in the example in comments.
> Sorry to seem rude, but our group of ~10 has been using bjam for nearly
> two years, and none of use are close to grokking it. I can tell by our
> messy Jamfiles that we're not using it as designed, but the
> documentation is nearly useless as to what the best practices are.

Let me look at the docs:

  The <source>X feature has the same effect on building a target as putting X in the list of
  sources. It is useful when you want to add the same source to all targets in the project (you can
  put <source> in requirements) or to conditionally include a source (using conditional
  requirements, see the section called “Conditions and alternatives”). See also the <library>

  This feature is almost equivalent to the <source> feature, except that it takes effect only for
  linking. When you want to link all targets in a Jamfile to certain library, the <library> feature
  is preferred over <source>X -- the latter will add the library to all targets, even those that
  have nothing to do with libraries.

So, in your case both examples are equivalent, since the final step of building exe is linking.

- Volodya

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at