Module::Build with XS

This is mainly for my own future benefit. It has just taken me ages to discover how to build Perl modules using Module::Build when parts of the module are done with XS.

The Build.PL needs to contain:

    extra_compiler_flags => ['-Wall'],
    extra_linker_flags => ['-lfoo'],
    include_dirs  => ['.'],

where foo is whatever library you need to link against. The include_dirs specifies where to find the ppport.h file. Also, the build-requires must be like:

    build_requires => {
        'ExtUtils::CBuilder' => 0,
   },

Finally, unlike the old MakeMaker, XS modules should go in the right place in the lib/ tree, e.g. Foo::Bar should be lib/Foo/Bar.xs, there will probably also be a lib/Foo/Bar.pm already in that directory.

Explore posts in the same categories: Uncategorized

Tags: , ,

Both comments and pings are currently closed.