[C++-sig] Exposing classes

David Abrahams dave at boost-consulting.com
Wed Jul 27 19:42:18 CEST 2005


"Ira" <sheig222 at gmail.com> writes:

> A question on basics...
>
> Do all my exposed C++ symbols need to be in .dll format (win32 of
> course)?

No.

> What I mean is, can I have an exe running a python intrpreter where exposed
> symbols are compiled *inside* the exe and somehow be able to access them
> from the python scripts?

Yes.

> How would I import the modules in such a case?

Just use import in your Python code, but of course your C/C++ code
needs to register the module first.  There's an example of this in the
libs/python/test/ directory.  See embedding.cpp.  The awful Jamfile
incantation needed to build and run it portably is:

    import testing ;

    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)
      ;

HTH,

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




More information about the Cplusplus-sig mailing list