Python inside C++

Ken Seehart ken at seehart.com
Tue Apr 14 06:47:19 EDT 2009


AJ Mayorga wrote:
>
> Hello all,
>
>  
>
> I am looking for a way  to statically compile pythonxx.dll into my C++ 
> application, so that I can use It as an internal scripting language 
> and either run the native python code or take an ELF from 
> py2exe/pyinstaller and run that.
>
> The machines that will have my C++ app running on them do not have 
> python and I cannot install it as part of my application. Any Ideas?
>
>  
>
> AJ
>
> ------------------------------------------------------------------------
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>   
Sure, that's easy.

http://www.python.org/doc/2.5.2/ext/embedding.html

That should do what I think you want.

Picky note: The phrase "statically compile pythonxx.dll into my C++ 
application" is not quite correct.  A DLL is dynamically linked, not 
statically linked.  All this means is that you ship pythonxx.dll with 
your application along with any other DLLs and pyd files you might 
need.  But don't worry, you can do what you want.

Terms:
Embedding = Using python inside an application that is written in 
another language (usually C/C++).  This is what you are asking about.
Extending = Making your C/C++ code callable from python.  (there are 
actually several alternatives available, but that is another topic).

Enjoy,
Ken




More information about the Python-list mailing list