Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Interface Perl with C++

by Anonymous Monk
on Dec 01, 2005 at 13:59 UTC ( [id://513273]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

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

Replies are listed 'Best First'.
Re: Interface Perl with C++
by Fletch (Bishop) on Dec 01, 2005 at 14:08 UTC
      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.

        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.

        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: Interface Perl with C++
by ton (Friar) on Dec 01, 2005 at 19:17 UTC
    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++
by Roger (Parson) on Dec 02, 2005 at 14:03 UTC
    I recommend Perl XS with C++. There is an example on access member functions from Perl.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://513273]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (8)
As of 2024-04-24 12:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found