[C++-sig] Re: Newbie needs advice for decision.
RaoulGough at yahoo.co.uk
Sun Apr 4 12:31:37 CEST 2004
Billy Gnosis <sirbender at freenet.de> writes:
> Hi I want to extend and more important embed Python in my Programs.
> 1. What is the best (easiest way) to extend Python with C++ ? Swig or
> Boost.Python, or is there something easier ?
I haven't used Swig, so I can't really compare them. Using
Boost.Python is pretty easy once you get into it, but it will probably
take a little bit of effort to get there (see the tutorial to get an
> 2. What is the best (easiest way) to embed Python in a C++ Program ?
> Boost.Python, the Python/C Api, or is there something easier out there
Boost.Python doesn't provide a lot of support for embedding Python. It
does basic stuff like managing reference counts for you and so on, but
doesn't currently wrap much of the Python/C API.
> 3. General Question: I played a little bit wit the high level
> embedding of the python interpreter in my C++ Program (#include
> "Python.h", Py_Initialize()...etc.etc...). Can I somehow compile and
> link everything statically ? Meaning, I have one binary in the end,
> that already includes all necessary parts of the python interpreter -
> when I give this file somebody else, this should be enough to run it
> no installation of the python interpreter necessary, etc...
> Is this possible ?
I guess anything is possible since you have access to the Python
source code and could relink it anyway you want, given enough
effort. You'd probably do better to ask about this on the main Python
discussion group, since it's not specifically C++ related. I'm not
sure about any legal/licensing issues of doing this, and how much of
the Python library (i.e. .py or .pyc files) the interpreter needs to
have to get going.
More information about the Cplusplus-sig