Scroll to navigation

Module::Build::XSUtil(3pm) User Contributed Perl Documentation Module::Build::XSUtil(3pm)


Module::Build::XSUtil - A Module::Build class for building XS modules


Use in your Build.PL

    use strict;
    use warnings;
    use Module::Build::XSUtil;
    my $builder = Module::Build::XSUtil->new(
        dist_name            => 'Your-XS-Module',
        license              => 'perl',
        dist_author          => 'Your Name <>',
        dist_version_from    => 'lib/Your/XS/Module',
        generate_ppport_h    => 'lib/Your/XS/ppport.h',
        generate_xshelper_h  => 'lib/Your/XS/xshelper.h',
        needs_compiler_c99   => 1,

Use in custom builder module.

    package builder::MyBuilder;
    use strict;
    use warnings;
    use base 'Module::Build::XSUtil';
    sub new {
        my ($class, %args) = @_;
        my $self = $class->SUPER::new(
            generate_ppport_h    => 'lib/Your/XS/ppport.h',
            generate_xshelper_h  => 'lib/Your/XS/xshelper.h',
            needs_compiler_c99   => 1,
        return $self;


Module::Build::XSUtil is subclass of Module::Build for support building XS modules.

This is a list of a new parameters in the Module::Build::new method:

This option checks C99 compiler's availability. If it's not available, Build.PL exits by 0.
This option checks C++ compiler's availability. If it's not available, Build.PL exits by 0.

In addition, append 'extra_compiler_flags' and 'extra_linker_flags' for C++.

Genereate ppport.h by Devel::PPPort.
Genereate xshelper.h which is a helper header file to include EXTERN.h, perl.h, XSUB.h and ppport.h, and defines some portability stuff which are not supported by ppport.h.

It is porting from Module::Install::XSUtil.

Enable compiler warnings flag. It is enable by default.
If invoke Build.PL with '-g' option, It will build with debug options.




Copyright (C) Hideaki Ohno.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Hideaki Ohno <hide.o.j55 {at}>

2019-04-03 perl v5.38.2