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

Hi Monks,

I have my own C library and i want to access C functions from perl ,for that i am using perlxs. In perlxs i need to edit .xs file to write function prototypes in xs language.

Whether my approach is fine ??Is there any simple method to do this??

Yesterday i got to know that some modules are available in CPAN that writes these function prototypes into .xs file automatically.Is it true? Because i find xs language difficult to learn.Any idea??

Replies are listed 'Best First'.
Re: perlxs again..
by BrowserUk (Patriarch) on Jan 18, 2011 at 05:50 UTC

    Take a look at h2xs. This utility comes with Perl installations and attempts to take a C header file (.h) for a given C library and build an XS interface from it.


    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: perlxs again..
by Khen1950fx (Canon) on Jan 18, 2011 at 05:56 UTC
    InlineX::XS is a good place to start. Converting your C into XS can be as simple as: From your main distribution directory:
    perl -c -MInlineX::XS=PACKAGE lib/your/Module.pm