Calling 'C' routines from perl.

Discussion in 'Perl Misc' started by Prathap, Jun 25, 2009.

  1. Prathap

    Prathap Guest

    Hi All:


    Can someone let me know how to invoke a 'C' routine from perl. I
    have to develop an application
    that requires Perl and C interactions. I need to know this in
    detail. Please provide me with exmples or referances where I can learn
    this.

    Thanks for the help in advance.

    Regards,
    Prathap
    Prathap, Jun 25, 2009
    #1
    1. Advertising

  2. Prathap <> writes:

    > Can someone let me know how to invoke a 'C' routine from perl. I
    > have to develop an application


    I believe that the easiest way is to look at Inline::C.

    //Makholm
    Peter Makholm, Jun 25, 2009
    #2
    1. Advertising

  3. Prathap

    Ted Zlatanov Guest

    On Thu, 25 Jun 2009 09:16:23 -0700 (PDT) Prathap <> wrote:

    P> Can someone let me know how to invoke a 'C' routine from perl. I
    P> have to develop an application
    P> that requires Perl and C interactions. I need to know this in
    P> detail. Please provide me with exmples or referances where I can learn
    P> this.

    I've been happy with Swig. It works with C++ as well and generates glue
    libraries that work with Java and other languages.

    Ted
    Ted Zlatanov, Jun 25, 2009
    #3
  4. Prathap

    Prathap Guest

    On Jun 26, 1:44 am, Tad J McClellan <> wrote:
    > Prathap <> wrote:
    > >   Can someone let me know how to invoke a 'C' routine from perl.

    >
    >     perldoc -q ' C '
    >
    >         Where can I learn about linking C with Perl?
    >
    > --
    > Tad McClellan
    > email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


    Thanks for all the suggestions. Can you please explain with an example
    why and how swig is useful?
    How do I make C libraries and finally infoke them from Perl. It will
    be of great quick help for me.

    Regards,
    Prathap
    Prathap, Jun 25, 2009
    #4
  5. Prathap

    J. Gleixner Guest

    Prathap wrote:
    > On Jun 26, 1:44 am, Tad J McClellan <> wrote:
    >> Prathap <> wrote:
    >>> Can someone let me know how to invoke a 'C' routine from perl.

    >> perldoc -q ' C '
    >>
    >> Where can I learn about linking C with Perl?

    [...]
    >
    > Thanks for all the suggestions. Can you please explain with an example
    > why and how swig is useful?


    Can you please take the time to use your browser and find it yourself?

    > How do I make C libraries and finally infoke them from Perl. It will
    > be of great quick help for me.


    http://www.swig.org/
    J. Gleixner, Jun 25, 2009
    #5
  6. Prathap

    Prathap Guest

    On Jun 26, 5:59 am, Ben Morrow <> wrote:
    > Quoth Prathap <>:
    >
    > > On Jun 26, 1:44 am, Tad J McClellan <> wrote:
    > > > Prathap <> wrote:
    > > > >   Can someone let me know how to invoke a 'C' routine from perl.

    >
    > > >     perldoc -q ' C '

    >
    > > >         Where can I learn about linking C with Perl?

    >
    > > Thanks for all the suggestions. Can you please explain with an example
    > > why and how swig is useful?

    >
    > I would stay away from SWIG. Its primary purpose is to create bindings
    > for lots of different languages from one source file, and IME perl
    > extensions built with SWIG (e.g. the SVN bindings) tend to be somewhat
    > awkward to use.
    >
    > > How do I make C libraries and finally infoke them from Perl. It will
    > > be of great quick help for me.

    >
    > You give the impression that you haven't even written the C yet. You
    > need to do that first, and here is not the place to ask for help with
    > that. If you don't have a library that you know how to invoke from C,
    > you haven't a hope of invoking it from Perl.
    >
    > You also need to read some of the documentation you have been pointed
    > at, and try writing something for yourself. You will not get any useful
    > help here until you say something like 'I wrote an XS/Inline::C file
    > that looks like this, and I expected X, but I got Y instead'.
    >
    > Ben


    I will do that. Just wanted a simplified introduction to the concepts.
    Thanks for the referances you all have provided and I hope to get
    things moving quickly. Will come back if any queries on my
    experiments.

    Regards,
    Prathap
    Prathap, Jun 26, 2009
    #6
  7. Prathap

    Prathap Guest

    On Jun 26, 12:07 pm, Prathap <> wrote:
    > On Jun 26, 5:59 am, Ben Morrow <> wrote:
    >
    >
    >
    >
    >
    > > Quoth Prathap <>:

    >
    > > > On Jun 26, 1:44 am, Tad J McClellan <> wrote:
    > > > > Prathap <> wrote:
    > > > > >   Can someone let me know how to invoke a 'C' routine from perl..

    >
    > > > >     perldoc -q ' C '

    >
    > > > >         Where can I learn about linking C with Perl?

    >
    > > > Thanks for all the suggestions. Can you please explain with an example
    > > > why and how swig is useful?

    >
    > > I would stay away from SWIG. Its primary purpose is to create bindings
    > > for lots of different languages from one source file, and IME perl
    > > extensions built with SWIG (e.g. the SVN bindings) tend to be somewhat
    > > awkward to use.

    >
    > > > How do I make C libraries and finally infoke them from Perl. It will
    > > > be of great quick help for me.

    >
    > > You give the impression that you haven't even written the C yet. You
    > > need to do that first, and here is not the place to ask for help with
    > > that. If you don't have a library that you know how to invoke from C,
    > > you haven't a hope of invoking it from Perl.

    >
    > > You also need to read some of the documentation you have been pointed
    > > at, and try writing something for yourself. You will not get any useful
    > > help here until you say something like 'I wrote an XS/Inline::C file
    > > that looks like this, and I expected X, but I got Y instead'.

    >
    > > Ben

    >
    > I will do that. Just wanted a simplified introduction to the concepts.
    > Thanks for the referances you all have provided and I hope to get
    > things moving quickly. Will come back if any queries on my
    > experiments.
    >
    > Regards,
    > Prathap- Hide quoted text -
    >
    > - Show quoted text -


    Thanks everyone. I read perlxstut and wrote few samples and they work
    fine for me.

    Regards,
    Prathap
    Prathap, Jun 26, 2009
    #7
  8. Prathap

    Ralph Malph Guest

    Prathap wrote:
    > Hi All:
    >
    >
    > Can someone let me know how to invoke a 'C' routine from perl. I
    > have to develop an application
    > that requires Perl and C interactions. I need to know this in
    > detail. Please provide me with exmples or referances where I can learn
    > this.
    >
    > Thanks for the help in advance.
    >
    > Regards,
    > Prathap

    Sorry shitskin...no aid to the enemy.
    Ralph Malph, Jul 11, 2009
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Rich

    Proper serial routines ?

    Andrew Rich, Oct 4, 2003, in forum: Perl
    Replies:
    1
    Views:
    443
    Al Tobey
    Oct 24, 2003
  2. Soenke
    Replies:
    0
    Views:
    556
    Soenke
    Dec 28, 2005
  3. Matthew Hood

    How to create global Funtions & Routines

    Matthew Hood, Jun 24, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    1,921
    Matthew Hood
    Jun 25, 2003
  4. Danny Shevitz
    Replies:
    0
    Views:
    253
    Danny Shevitz
    Mar 15, 2011
  5. Replies:
    10
    Views:
    162
    Tim Greer
    Oct 14, 2008
Loading...

Share This Page