views:

79

answers:

2

I'm looking for a simple example code for C++\IronPython integration, i.e. embedding python code inside a C++, or better yet, Visual C++ program.

The example code should include: how to share objects between the languages, how to call functions\methods back and forth etc...

Also, an explicit setup procedure would help too. (How to include the Python runtime dll in Visual Studio etc...)

I've found a nice example for C#\IronPython here, but couldn't find C++\IronPython example code.

A: 

I'm afraid the answer is no, there is no simple way to integrate IronPython into a C++/CLI application.

The reason is that IronPython is implemented on top of the Dynamic Language Runtime (DLR), therefore using the services provided by this infrastructure. You may trivially use IronPython from C# (also running on top of DLR), but I doubt you can call it from C++/CLI unless somebody backports IronPython to it.

jsalonen
@jsalonen, I'll accept your answer if you could add references or if you'll receive community votes. Sorry for being tough, but I really hope there's someone out there with a better answer ;)
Jonathan
There is no reason that IronPython would not work from C++/CLI or any other .NET language - it's just a .NET library. It's not tied to C# in any way.
Jeff Hardy
+2  A: 

If you don't need .NET functionality, you could rely on embedding Python instead of IronPython. See Python's documentation on Embedding Python in Another Application for more info and an example. If you don't mind being dependent on BOOST, you could try out its Python integration library.

Jonathan