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

Is there a beginners guide to using ExtUtils::XSpp? I am a little confused reading the POD of the module. I still can't figure out how to get started on using this module to consume C++ code. I guess, I'm looking for something like perlxstut, which starts with step 1 of generating the template.

I figured, a better place to start might be with the example but I am not sure if just directly building it (since Build.PL is provided) would help me understand how to use this module. But alas, that is not the case. It bails out on me with the error "Need ExtUtils::Typemap as argument". So I wasn't sure how to even use the example provided. And there is no README file provided with it to understand how to actually use it.

So, do I start by first creating the typemaps for each C++ class I have? What does xspp command generate? I think my confusion is so much, I don't even know what question to ask :(. Thanks for your help.

Replies are listed 'Best First'.
Re: ExtUtils::XSpp usage for a novice
by Anonymous Monk on Aug 31, 2011 at 04:57 UTC
Re: ExtUtils::XSpp usage for a novice
by cheako (Beadle) on Feb 27, 2015 at 06:59 UTC

    A tutorial would be nice. Here is what I've done.

    h2xs -A -n Bitcoin::Address added #include <bitcoin/address.hpp> to Address.xs building the project blows up spectacularly, cc can't handle hpp files.

    Running xspp does nothing, there are no files for it to work with.

    We are cpp novices, but proficient in c and xs.

      And then what happend?

        What part of "blows up spectacularly" are you having trouble with?

        cc can't parse headers meant to be pares by cpp, it's plain wrong to even try. Knowing that I've the wrong tutorial(for C using h2xs) is only half the battle.

        We are asking for the XSpp tutorial for novice, given that there is no hpp2xs. Looking for a fill in the blanks boilerplate, the example with animals and dogs is too beefed up. It's not explained what can and can't be purged or what to do to get started with your own project. One note is that it does not interface with any library.

Re: ExtUtils::XSpp usage for a novice
by Khen1950fx (Canon) on Aug 31, 2011 at 05:12 UTC
    Need ExtUtils::Typemap as argument

    ExtUtils::Typemap is a wrapper around ExtUtils::Typemaps which a part of ExtUtils::ParseXS. The name was changed to prevent collisions on case-insensitive systems.

    In order to use ExtUtils::Typemap, there are a few non-core dependencies that need to be installed:

    #!/usr/bin/perl use strict; use warnings; use CPAN; use CPAN::Shell->install(qw( install Spiffy ExtUtils::Typemap ExtUtils::Typemaps::Default));
    Try that, then give it another shot.

      In order to use ExtUtils::Typemap, there are a few non-core dependencies that need to be installed:

      And Spiffy isn't one of them -- cpan does a bangup job of figuring out dependencies on its own, it doesn't really need any help

      No. I suggest that you do some more research. You undershot the runway:). Spiffy is a dependency of ExtUtils::XSpp.

        No. I suggest that you do some more research. You undershot the runway:). Spiffy is a dependency of ExtUtils::XSpp.

        What more research? Shall I quote your own words for you again?

        Ok, you said

        In order to use ExtUtils::Typemap, there are a few non-core dependencies that need to be installed:

        ExtUtils::XSpp is not ExtUtils::Typemap, and Spiffy is not a dependency of ExtUtils::Typemap

        cpan doesn't need help figuring out dependencies, core or otherwise -- this is what the utility is all about

        All your spiffy program does is make folks think

        perl/cpan must be really FUBARed that you need to write a program to install some module

        when you don't, since cpan ExtUtils::Typemap installs everything required

        Btw, 1297 nodes and you're still replying to yourself? Clicking the correct reply link can't be that hard :/

Re: ExtUtils::XSpp usage for a novice
by cheako (Beadle) on Mar 02, 2015 at 04:02 UTC

    Short version:
    h2xs -An My::Module
    cd My-Module
    rm Makefile.PL
    cat >Build.PL

    use common::sense; use 5.006001; use Module::Build::WithXSpp; my $build = Module::Build::WithXSpp->new( module_name => 'My::Module', license => 'perl', dist_author => q{John Doe <john_does_mail_address>}, dist_version_from => 'lib/My/Module.pm', build_requires => { 'Test::More' => 0, }, extra_typemap_modules => { 'ExtUtils::Typemaps::ObjectMap' => '0', # ... }, # extra_linker_flags => [qw(-lfoo)], # early_includes => [qw(<foo.hpp>)], ); $build->create_build_script;

    mkdir src xsp
    # cat > src/anythingwhatever.cc
    cp /usr/include/foo.hpp xsp/foo.xsp
    $EDITOR xsp/foo.xsp

    Syntax for .xsp files is still unknown to me, but you'll be hitting shift-5 allot.

    After that it's modules as usual, use ./Build.PL to configure and make to build.