Embedding Python into C++

Apr 13, 2011 at 10:49am
Hey Guys

Firstly, this is my 1st post, So hello to everyone :)

I just want to check if anyone has any idea if its possible to embed Python ( or any other language for that matter) Into C++ code.

If so how is this done?

Thanks for your time!
Apr 13, 2011 at 11:12am
If by "embed" you mean having their codes in one file, than no.
If you want to call some python code from your c++ program you'll have to use some library. A quick search gave me http://www.boost.org/doc/libs/1_46_1/libs/python/doc/
Apr 13, 2011 at 11:39am
Hi,

From http://www.swig.org/exec.html:

SWIG is an interface compiler that connects programs written in C and C++ with scripting languages such as Perl, Python, Ruby, and Tcl. It works by taking the declarations found in C/C++ header files and using them to generate the wrapper code that scripting languages need to access the underlying C/C++ code.


This is useful if you have C++ library that you want to use from a scripting language, but not the other way around AFAIK.

Haven't used it for ages, but when I did it had difficulties with C++ templates - you may want to be wary of that.
Apr 13, 2011 at 12:48pm
Thanks guys :)
Topic archived. No new replies allowed.