[C++-sig] Re: Embedded Python plus module loading

David Abrahams dave at boost-consulting.com
Mon Mar 21 09:52:09 CET 2005


Daniel Holth <dholth at fastmail.fm> writes:

> I've figured it out, more or less. When I link to libpython2.3.so rather
> than the static Python library it works fine. Doesn't answer the
> question of why my other program suddenly stopped working re: importing,
> but it does fix it.
>
> # The boost-jam embedding example
> exe embedding
>         : # sources
>         embedding.cpp
>         : # requirements
>         <threading>multi        # my system's Python library is threaded
>         <find-library>python2.3
>         <find-library>boost_python
>         ;
>
> which imports sha without incident. Except it doesn't set the include
> path, so the same jamfile won't both compile my code and link it. So now
> I just have to work out the arguments to get it to link with the shared
> library and set the include path properly... perplexing.
>
> Thanks for any advice,

The embedding example in libs/python/test/Jamfile looks like:

    run ../test/embedding.cpp <lib>../build/boost_python
      : # program args
      : # input files
      : # requirements
      $(PYTHON_PROPERTIES)
        <define>BOOST_PYTHON_STATIC_LIB
        <define>BOOST_PYTHON_STATIC_MODULE
        <library-path>$(PYTHON_LIB_PATH)
          <$(gcc-compilers)><debug-python><library-path>$(CYGWIN_PYTHON_DEBUG_DLL_PATH)
            <$(gcc-compilers)><*><library-path>$(CYGWIN_PYTHON_DLL_PATH)
              <find-library>$(PYTHON_EMBEDDED_LIBRARY)

<define>BOOST_PYTHON_STATIC_LIB is not needed if you're using the
shared version of Boost.Python.

You can use <dll>@boost/libs/python/build/boost_python if you are
using the cross-project dependencies to ensure that the right shared
library is built and linked in.

HTH,

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list