in reply to Re: Problem on XS
in thread Problem on XS module loading

I guessed it might be caused by C++ issue. But in document perlxs, there is a chapter of "using XS with C++", so there may be some magics?

Replies are listed 'Best First'.
Re^3: Problem on XS
by BrowserUk (Patriarch) on Oct 28, 2011 at 04:56 UTC
    so there may be some magics?

    Truthfully, I don't know. I know enough to diagnose the problem, but not enough to resolve it.

    From what I see in that section -- and the rest of the document -- there doesn't appear to be any mention of how to persuade the C++ compiler to not mangle the names of Perl's C APIs called from within the XS code. The normal way of doing this -- thereby allowing C apis to be called from C++ code -- is to use extern "C"{} as described here

    As far as I can tell that would require you to modify Perl's header files, which doesn't seem right.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^3: Problem on XS
by Anonymous Monk on Oct 28, 2011 at 07:33 UTC

    so there may be some magics?

    IIRC, last time you asked about XS/C++ you got links to several working examples, which show

    #ifdef __cplusplus extern "C" {

    So what do you have?

      It seems the problem is g++ modified the symbol name of perl API provided by perl headers, so I tried to surround perl headers within extern:
      extern "C" { #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" #include <stdio.h> }
      But this does not help at all...
        Well, maybe you should not be using g++