1

Boost using this build system I'm not otherwise familiar with, based on "Jam" files. Now, I've forked and cloned a specific Boost library (program_options), and I want to build it and perhaps also run the tests. I notice a build/Jamfile.v2 - what should I do with it?

I tried apt-get install jam on my distribution, but that did not get me very far:

$ jam -fbuild/Jamfile.v2
warning: unknown rule project
warning: unknown rule boost-lib
don't know how to make all
...found 2 target(s)...
...can't find 1 target(s)...

Also, do I have to get the absolute latest development version of all of Boost to build the cloned library against, or can I use a local boost release I already have?

Notes:

  • I'm on a recent GNU/Linux distribution (Mint 18.3 but this shouldn't matter).
einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • 1
    I doubt any boost library can be built in isolation. And I certainly would not recommend building a boost library against a different version of boost. Just build the whole boost. It is a pain in the neck, but I did it in the past, it only takes a day or two to figure out terrible bjam. – SergeyA Feb 09 '18 at 21:50
  • I'm with @SergeyA. A nice hybrid that works well for header-only libs is just to put the include directory first in your includes and have a regular boost installed elsewhere. – sehe Feb 10 '18 at 11:47

2 Answers2

1

What I've done, based on @SergeyA and others' advice, is:

  1. Clone all of Boost, recursively (see this page (this will create a boost/ folder )
  2. cd boost
  3. in .git/modules/my_boost_lib/config, change the origin URL to your fork
  4. in .gitmodules, under [submodule "my_boost_lib"], change the URL to your fork
  5. execute git submodule update --init libs/my_boost_lib/ (perhaps after deleting that library; not sure if that's actually necessary)
  6. cd libs/my_boost_lib/build
  7. ../../../b2

The latter works because b2 looks for a Jamfile.v2 in its current working directory, and that file exists and is intended to build just the library. The build results will be located outside of libs/my_boost_lib though.

Note: To build run the library tests, build the same way but from libs/my_boost_lib/test.

einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • Another nice command to know is `./b2 headers` - which updates all linked headers in the global include directory in case you have updated header-only libraries in their own repositories. – sehe Feb 11 '18 at 01:01
0

Essentially the build steps is

  1. Run bootstrap to build the build tool b2
  2. Build boost with b2 install or similar. You may want to provide options to it.

Read more in the boost getting started document: http://www.boost.org/doc/libs/1_66_0/more/getting_started/index.html (hint, look at lower right to go to next page..)

If you are on windows / VS2017, the use of vcpkg to get boost is very easy.

einpoklum
  • 118,144
  • 57
  • 340
  • 684
digimatic
  • 16
  • 2
  • 1. There is no `bootstrap` to run. 2. I don't want to build boost, I just want to build this library. To the extent it depends on other Boost code - I want it to use the (full) version of Boost I have installed on my system. – einpoklum Feb 09 '18 at 22:24