Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: some questions about example 4 of perlxstut

by syphilis (Archbishop)
on Jun 30, 2019 at 14:11 UTC ( [id://11102177]=note: print w/replies, xml ) Need Help??


in reply to some questions about example 4 of perlxstut

Why when I run perl Makefile.PL on Mytest2 level, there also build a makefile on Mytest2/mylib directory?

I think that's something that's done by EU::MM. When perl Makefile.PL is run, it seems that perl searches recursively through the directories below the current one, and executes all Makefile.PL files that it finds.
If I create a Mytest2/bogus/Makefile.PL that contains simply warn "\nHello World\n"; then I see Hello World appear in the output when I run perl Makefile.PL in the Mytest2 directory.
Also, if I remove Mytest2/mylib/Makefile.PL then its absence is not detected during the initial "perl Makefile.PL" step.

I lookup on cpan, like gtk2, EV and Tk, It seems there are own way to do

The gtk2 modules are faced with a challenge quite different to that of Example 4.
With Example 4, the challenge is to access functionality that has been included with the Mylib2 source, whereas the gtk2 modules have to access functionality in the gtk2 libraries - which are 3rd party libraries not provided by the module's source distribution.
The XS files provided by the gtk2 modules simply provide the glue that enables access to those external libraries, though they also rely on linking to those external libraries and on including their headers.
Not sure about Tk or EV.

For mine, the links provided by Anonymous Monk are more worthy of attention than this rather pathetic perlxstut that specifies ad-hoc code (not all of which can be copy'n'pasted), and reliance upon h2xs.
I should add that I've never used (and likely never will use) h2xs, and am therefore perhaps not fully appreciative of what it has to offer.

Cheers,
Rob

Replies are listed 'Best First'.
Re^2: some questions about example 4 of perlxstut
by Anonymous Monk on Jul 01, 2019 at 04:51 UTC

    Thanks Rob, I usually use Inine::C to call some C functions from a library or create a skeleton of XS module, it's very handy, and I haven't touched h2xs for long time also. But as you said, example 4 is aim to access to functions in source, in this scenario, Inline C is not very suitable I think, although what h2xs shows in example 4 in perlxstut is not good either.

    So what's the good way to generate XS (automatically) for access to a large source distribution? I'll look up ExtUtils::XSpp, hope it's a right way to go.

      So what's the good way to generate XS (automatically) for access to a large source distribution?

      I don't know - it's not something I've done, and Example 4 would indicate that a large amount of hand-editing of the XS file that's generated by h2xs would be required.
      However, you might find something useful in perldoc Inline::C::Cookbook.
      For example there's a small section headed "Replacing h2xs" that seems to discuss this very issue, though it's thin on detail and I don't understand it.

      FAIRK, maybe that fiddly "Example 4" is, in fact, as good a way as any ?

      Cheers,
      Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11102177]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-18 13:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found