[C++-sig] bjam rules for building embedded applications

Graeme Lufkin gwl at u.washington.edu
Fri Apr 30 18:25:33 CEST 2004


	Looking at the new(ish) example/Jamfile, I've (I think) figured out the
recommended way to build Boost.Python extensions.  Extrapolating the
idea, I've created a similar Jam template for embedding applications. 
Please critique it, to verify that I'm correctly understanding how bjam
works in this instance.  If members of the list agree with my
understanding, I can update and submit diffs of the tutorial, which
still uses old-style Jamfiles for both extensions and embedding.
	To build an extension, you use the extension rule and include the
extension template (<template>@boost/libs/python/build/extension, where
@boost is defined in the Jamrules file to point at the boost source
tree) in the list of sources.  This will build two shared libraries in
the bin directory, libboost_python.so and your extension.  The template
checks for updates to the Boost.Python source and automatically
rebuilds.
	To build an embedded application, we will use the exe rule and an
embedding template defined below.  This template should get added to
libs/python/build/Jamfile in the Boost sources.

  template embedded
    : <lib>boost_python #embedded needs static library, not dynamic
    : <sysinclude>../../.. #boost headers
	$(BOOST_PYTHON_V2_PROPERTIES) #Python include/linking dirs
	<find-library>$(PYTHON_EMBEDDED_LIBRARY) #libpython
	<find-library>pthread #needed for my system
    ;

This template is used exactly as the extension template, for example in
the Jamfile:
exe embedded_test
  : embedded_test.cpp
  <template>@boost/libs/python/build/embedded
  ;
This will build libboost_python.a (a static library) and your
executable, again checking for updates in the Boost.Python source tree.

	Okay, some notes: I needed to add the <find-library>pthread on my
system (RH9, gcc 3.2.2, Python 2.2.2).  If this isn't only observed on
my system, it should probably be added to the definition of
$(PYTHON_EMBEDDED_LIBRARY) in tools/build/v1/python.jam
	The tutorial (both the extending and embedding examples) uses Jamfiles
with lots of other stuff that (at best) doesn't appear to be necessary
and (at medium) is confusing to the reader and (at worst) doesn't work
anymore.  I volunteer to update the tutorial on this point.  Are diffs
to the CVS version submitted to this list the appropriate way to do
this?

	Some questions: If I've got several separate programs (either
extending, or embedding) using this technique, then each one has their
own version of libboost_python.[a|so] which seems rather wasteful.  Is
there a recommended way to use a libboost_python.[a|so] in a fixed
location?  That is, please provide a Jamfile entry to do this.
	When building all of boost (that is, running bjam in $(BOOST_ROOT) ) it
makes several versions (compiler/threading/debug) of the libraries (not
just Boost.Python) and (optionally) installs them to a given location. 
Could the extension and embedded templates be reworked to link against
these versions of libboost_python, so that (as requested above) there is
only one source of the library to link against?  How might this be done?
	Thanks very much for your patience reading this long message.
-- 
	- Graeme Lufkin
	gwl at u.washington.edu
"This sentence contains exactly threee erors."





More information about the Cplusplus-sig mailing list