h2xs
creates Perl extension module skeletons
TLDR
SYNOPSIS
h2xs [options] [headerfile ...] [extralibraries_]
DESCRIPTION
h2xs builds a Perl extension skeleton from C header files. It generates XS code to wrap C libraries, making their constants and functions accessible from Perl, along with a `Makefile.PL`, `.pm` module file, `.xs` file, and test stubs.If no module name is supplied with `-n`, the name of the first header file is used with its first character capitalised. Extra libraries needed at link time can be appended on the command line in the form `-lm -lposix`, optionally with `-L/path` to add a library search directory.The tool can also create a skeleton pure Perl module (no XS) by using the `-X` flag.
PARAMETERS
HEADERFILE
One or more C header files to parse for `#define` constants and function declarations.EXTRALIBRARIES_
Extra libraries to link against, in the form `-lm -lposix`, optionally with `-L/path` to add search directories.-n, --name=MODULENAME_
Specify the name for the extension, e.g. `RPC::DCE`. If omitted, the name of the first header file (capitalised) is used.-A, --omit-autoload
Omit all AutoLoader facilities. Removes `use AutoLoader` from the .pm file and implies `-c`.-X, --omit-XS
Omit the XS portion and generate a skeleton pure Perl module. Implies `-c` and `-f`.-c, --omit-constant
Omit `constant()` from the .xs file and the corresponding `AUTOLOAD` from the .pm file.-O, --overwrite-ok
Allow an existing extension directory to be overwritten.-b, --compat-version=VERSION
Generate a .pm file backwards-compatible with the specified Perl version (e.g. `5.005_03`). Versions below 5.6.0 avoid `our` and `use warnings`.-B, --beta-version
Use an alpha/beta-style version number (`0.00_01`) instead of `0.01`.-C, --omit-changes
Omit creation of the `Changes` file and add a `HISTORY` section to the POD template instead.-F, --cpp-flags=FLAGS
Additional flags to pass to the C preprocessor when scanning headers. Also written into the generated `Makefile.PL`.-M, --func-mask=REGEX
Select only functions and macros whose names match the given regular expression.-P, --omit-pod
Omit the autogenerated stub POD section.-a, --gen-accessors
Generate accessor methods for each element of structs and unions found in the header.-d, --debugging
Turn on debugging messages.-e, --omit-enums[=REGEX]
Skip constants defined in C enumerations. If a regex is given, skip only enums whose names match it.-f, --force
Allow creating an extension for a header that is not found in standard include directories.-g, --global
Include code for safely storing static data in the .xs file.-k, --omit-const-func
For function arguments declared as `const`, omit the `const` attribute in the generated XS code.-m, --gen-tied-var
(Experimental) Declare Perl variables magically tied to C variables of the same name.-o, --opaque-re=REGEX
Treat C types matched by the regex as opaque data types even if they appear in typemaps. Use with `-x`.-p, --remove-prefix=PREFIX
Remove the given prefix from Perl function names (e.g. `-p secrgy`).-s, --const-subs=SUB1,SUB2
Create Perl subroutines for the specified macros (assumed `char *` return type) rather than using the `constant()` mechanism.-t, --default-type=TYPE
Internal type used by `constant()` for macros. Defaults to `IV` (signed integer).-v, --version=VERSION
Set the version number for the extension. Defaults to `0.01` (or `0.00_01` with `-B`).-x, --autogen-xsubs
Automatically generate XSUBs from function declarations in the header. Requires the `C::Scan` module.--skip-exporter
Do not use `Exporter` or export any symbols.--skip-ppport
Do not use `Devel::PPPort` (disables portability to older Perl versions).--skip-autoloader
Do not use `AutoLoader`, but keep the `constant()` function and `AUTOLOAD` sub for constants.--skip-strict
Do not add `use strict` to the generated module.--skip-warnings
Do not add `use warnings` to the generated module.--use-new-tests
When `-b` is in effect, generate tests using `Test::More` rather than the older `Test` module.--use-old-tests
Force generation of tests using the older `Test` module.-h, -?, --help
Print usage and version information and exit.
CAVEATS
Generated code frequently needs manual customisation. Complex C APIs (function pointers, arrays, non-integer types) require hand-editing of the XS file and typemap. The `-x` option requires the `C::Scan` CPAN module to be installed.
HISTORY
h2xs has been part of Perl since version 5, providing the standard way to create XS extension modules.
