[C++-sig] Re: Re: Re: Problem with vc++ 7

David Abrahams dave at boost-consulting.com
Wed Nov 27 00:25:41 CET 2002


"Mike Rovner" <mike at bindkey.com> writes:

> My fault! I misinterpreted <dll>... as dependency 

It _is_ a dependency.

> That is my first attempt to suggest changes, so please be patient and lead
> me through.
>
> Suggested text:
>
> Using bjam to build python extensions
> =========================
>
> bjam is a standard tool for building boostlibrary itself. Thus it is
> preferable way to build python extensions based on boost.python with
> bjam.  Basic example listed in tutorial.
>
> However if you want to add external libraries in your extension (that is why
> you use boost.python, isn't it?), you must add them to dependency
> section:

No, you must add them to the requirements section. Please see
http://www.boost.org/tools/build/build_system.htm#main_targets
>
> # Specify our location in the boost project hierarchy
> subproject libs/python/MyExtension ; ##################### if you put your
> dir in boost hierarchy
>
> # Include definitions needed for Python modules
> SEARCH on python.jam = $(BOOST_BUILD_PATH) ;
> include python.jam ;
>
> # Declare a Python extension
> extension Example
> :  # sources
>    Example.cpp
>    <dll>../build/boost_python
>
> :  # dependencies
>    <include>FULL_PATH_INCLUDE_DIR
>    <include>RELATIVE_PATH_INCLUDE_DIR
>    <library-file>FULL_PATH.lib
>    <library-path>PATH_TO_LIB
>    <library-file>LIBNAME.lib
>   ;
>
> # Declare a test for the extension module
> boost-python-runtest test1
>     :  # Python test driver
>     test1.py
>     # extension modules to use
>     <pyd>Example ;
>
> Keeping your projects under boost hierarchy is often inconvenient. You may
> adjust Jamfile to build your extension from any place by
> - specifying BOOST_BUILD_PATH environment variable pointing to the root of
> your boost tree or

No, BOOST_BUILD_PATH would have to point at the tools/build
subdirectory, but this is really only supposed to be used for *adding*
additional stuff to the build system (e.g. user-defined toolsets). You
should always use the approach below:

> - copying boost-build.jam file to some place in (or above) your source
> directory

You need to change the contents so that it reads:

   boost-build <path-to-boost>/tools/build ;

No point in copying it; it's just one line anyway.

> and changing the line subproject to the
>     project-root ;
> in the Jamfile.

Or you can establish a new project and make your Jamfile reside in a
subproject.

> ---------------
> See also
> http://www.python.org/cgi-bin/moinmoin/boost_2epython_2fBuildingExtensions

Hmm, why don't you just add your info to the Wiki?

> BTW, still open question: How to specify library in a platform-independent
> way?

You could do something like:

    local libname
    if $(NT)
    {
       libname = foo.lib
    }
    else
    {
       libname = libfoo.a
    }

        ...

        <library-file>$(libname)

-- 
                       David Abrahams
   dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution





More information about the Cplusplus-sig mailing list