Interface Perl with C++
Anonymous Monk
created: 2005-12-01 08:59:51
Hi venerable Monks,
Kindly let me know:-
How to access C++ functions. For Example if there is a function Func defined in Example class, Example::Func(). I want to acces this in Perl.
Anns
Re: Interface Perl with C++
created: 2005-12-01 09:08:26

See Inline::CPP, perlxstut, perlembed.

Re^2: Interface Perl with C++
created: 2005-12-01 09:32:09
Some suggested to use SWIG. How is this different from the one you have mentioned. My aim is to glue components written in C++ using Perl. It would be great if you could throw some light on this.

Thanks in advance.
Re^3: Interface Perl with C++
created: 2005-12-01 09:45:52
I second the first suggestion. The easiest way is to use Inline for your language. Other approaches are far more complex.

The docs, for all the Inline modules I've looked at, are clear.

Phil

Re^3: Interface Perl with C++
created: 2005-12-01 09:47:59

SWIG is another option, but I've never personally (directly) used it. It allows wrapping a library from several different languages with the same SWIG interface code (so you do the SWIG part once and get a Perl interface, a Python interface, a TCL interface, . . .). If you might want to interface from multiple languages then definately take a look at SWIG, otherwise Inline::Cpp is probably going to be the easiest route.

Re: Interface Perl with C++
ton
created: 2005-12-01 14:17:29
I'd actually recommend rewriting the C++ functions in C and using Inline::C coupled with Perl's "object oriented" features. But I guess that depends on whether you want to write fast code or write code faster.

-----
Be bloody, bold, and resolute; laugh to scorn
The power of man...
Re: Interface Perl with C++
created: 2005-12-02 09:03:56
I recommend Perl XS with C++. There is an example on access member functions from Perl.

perlmonks.org content © perlmonks.org and Anonymous Monk, Fletch, philcrow, Roger, ton

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03