Interfacing C++ and Perl seems to be a somewhat underdocumented subject; so far I have only managed to find the following:

  1. John Keiser's Gluing C++ And Perl Together
  2. Dean Roehrich's XS CookBooks
However, neither of these really touch on writing frontends to C++ libs, just standalone code.

If anyone can suggest a better forum for this, or source of documentation specific to what I'm trying to do, when please tell me. If not, and you have any experience of what I'm trying to do, read on ...

I've been comsistently encountering two errors - one of which occurs whenever I try and access an overloaded method, e.g:

MyModule.c:64: no matching function for call to `Mysettings::set (cons +t string *, const string *)' /usr/local/include/mysettings.h:66: candidates are: void Mysettings::s +et(const string &, const string &) /usr/local/include/mysettings.h:74: void Mysettings::s +et(const string &, const char *) /usr/local/include/mysettings.h:82: void Mysettings::s +et(const string &, int) /usr/local/include/mysettings.h:90: void Mysettings::s +et(const string &, double) /usr/local/include/mysettings.h:98: void Mysettings::s +et(const string &, bool)

The second occurring when accessing methods which return an object of a differing class to the owner of the method, e.g

MySet MyEnquire::get_set(first, maxitems)
Produces the error:
MyModule.c: In function `void XS_MyModule__Enquire_get_set(CV *)': MyModule.c:567: cannot convert `RETVAL' from type `MySet' to type `voi +d *

I've tried googling for '"cannot convert `RETVAL' from type `MySet"', which turns up absolutely no results; and '"no matching function for call to" XS', which turns up ones of little relevance.

Anyone know how to deal with these problems?

n.b. Before anyone suggests it, I have tried generating the XS code with SWIG, but had even less success with it.


In reply to Writing XS frontends to C++ libraries. by kilinrax

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.