{
    "mode": "perldoc",
    "parameter": "XSLoader",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/XSLoader/json",
    "generated": "2026-10-06T03:07:25Z",
    "synopsis": "package YourPackage;\nrequire XSLoader;\nXSLoader::load(PACKAGE, $VERSION);",
    "sections": {
        "NAME": {
            "content": "XSLoader - Dynamically load C libraries into Perl code\n",
            "subsections": []
        },
        "VERSION": {
            "content": "Version 0.32\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "package YourPackage;\nrequire XSLoader;\n\nXSLoader::load(PACKAGE, $VERSION);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module defines a standard *simplified* interface to the dynamic linking mechanisms\navailable on many platforms. Its primary purpose is to implement cheap automatic dynamic loading\nof Perl modules.\n\nFor a more complicated interface, see DynaLoader. Many (most) features of \"DynaLoader\" are not\nimplemented in \"XSLoader\", like for example the \"dlloadflags\", not honored by \"XSLoader\".\n\nMigration from \"DynaLoader\"\nA typical module using DynaLoader starts like this:\n\npackage YourPackage;\nrequire DynaLoader;\n\nour @ISA = qw( OnePackage OtherPackage DynaLoader );\nour $VERSION = '0.01';\nPACKAGE->bootstrap($VERSION);\n\nChange this to\n\npackage YourPackage;\nuse XSLoader;\n\nour @ISA = qw( OnePackage OtherPackage );\nour $VERSION = '0.01';\nXSLoader::load(PACKAGE, $VERSION);\n\nIn other words: replace \"require DynaLoader\" by \"use XSLoader\", remove \"DynaLoader\" from @ISA,\nchange \"bootstrap\" by \"XSLoader::load\". Do not forget to quote the name of your package on the\n\"XSLoader::load\" line, and add comma (\",\") before the arguments ($VERSION above).\n\nOf course, if @ISA contained only \"DynaLoader\", there is no need to have the @ISA assignment at\nall; moreover, if instead of \"our\" one uses the more backward-compatible\n\nuse vars qw($VERSION @ISA);\n\none can remove this reference to @ISA together with the @ISA assignment.\n\nIf no $VERSION was specified on the \"bootstrap\" line, the last line becomes\n\nXSLoader::load(PACKAGE);\n\nin which case it can be further simplified to\n\nXSLoader::load();\n\nas \"load\" will use \"caller\" to determine the package.\n",
            "subsections": [
                {
                    "name": "Backward compatible boilerplate",
                    "content": "If you want to have your cake and eat it too, you need a more complicated boilerplate.\n\npackage YourPackage;\n\nour @ISA = qw( OnePackage OtherPackage );\nour $VERSION = '0.01';\neval {\nrequire XSLoader;\nXSLoader::load(PACKAGE, $VERSION);\n1;\n} or do {\nrequire DynaLoader;\npush @ISA, 'DynaLoader';\nPACKAGE->bootstrap($VERSION);\n};\n\nThe parentheses about XSLoader::load() arguments are needed since we replaced \"use XSLoader\" by\n\"require\", so the compiler does not know that a function XSLoader::load() is present.\n\nThis boilerplate uses the low-overhead \"XSLoader\" if present; if used with an antique Perl which\nhas no \"XSLoader\", it falls back to using \"DynaLoader\".\n"
                }
            ]
        },
        "Order of initialization: early load()": {
            "content": "*Skip this section if the XSUB functions are supposed to be called from other modules only; read\nit only if you call your XSUBs from the code in your module, or have a \"BOOT:\" section in your\nXS file (see \"The BOOT: Keyword\" in perlxs). What is described here is equally applicable to the\nDynaLoader interface.*\n\nA sufficiently complicated module using XS would have both Perl code (defined in YourPackage.pm)\nand XS code (defined in YourPackage.xs). If this Perl code makes calls into this XS code, and/or\nthis XS code makes calls to the Perl code, one should be careful with the order of\ninitialization.\n\nThe call to XSLoader::load() (or bootstrap()) calls the module's bootstrap code. For modules\nbuild by xsubpp (nearly all modules) this has three side effects:\n\n*   A sanity check is done to ensure that the versions of the .pm and the (compiled) .xs parts\nare compatible. If $VERSION was specified, this is used for the check. If not specified, it\ndefaults to \"$XSVERSION // $VERSION\" (in the module's namespace)\n\n*   the XSUBs are made accessible from Perl\n\n*   if a \"BOOT:\" section was present in the .xs file, the code there is called.\n\nConsequently, if the code in the .pm file makes calls to these XSUBs, it is convenient to have\nXSUBs installed before the Perl code is defined; for example, this makes prototypes for XSUBs\nvisible to this Perl code. Alternatively, if the \"BOOT:\" section makes calls to Perl functions\n(or uses Perl variables) defined in the .pm file, they must be defined prior to the call to\nXSLoader::load() (or bootstrap()).\n\nThe first situation being much more frequent, it makes sense to rewrite the boilerplate as\n\npackage YourPackage;\nuse XSLoader;\nour ($VERSION, @ISA);\n\nBEGIN {\n@ISA = qw( OnePackage OtherPackage );\n$VERSION = '0.01';\n\n# Put Perl code used in the BOOT: section here\n\nXSLoader::load(PACKAGE, $VERSION);\n}\n\n# Put Perl code making calls into XSUBs here\n",
            "subsections": [
                {
                    "name": "The most hairy case",
                    "content": "If the interdependence of your \"BOOT:\" section and Perl code is more complicated than this\n(e.g., the \"BOOT:\" section makes calls to Perl functions which make calls to XSUBs with\nprototypes), get rid of the \"BOOT:\" section altogether. Replace it with a function onBOOT(), and\ncall it like this:\n\npackage YourPackage;\nuse XSLoader;\nour ($VERSION, @ISA);\n\nBEGIN {\n@ISA = qw( OnePackage OtherPackage );\n$VERSION = '0.01';\nXSLoader::load(PACKAGE, $VERSION);\n}\n\n# Put Perl code used in onBOOT() function here; calls to XSUBs are\n# prototype-checked.\n\nonBOOT;\n\n# Put Perl initialization code assuming that XS is initialized here\n"
                }
            ]
        },
        "DIAGNOSTICS": {
            "content": "\"Can't find '%s' symbol in %s\"\n(F) The bootstrap symbol could not be found in the extension module.\n\n\"Can't load '%s' for module %s: %s\"\n(F) The loading or initialisation of the extension module failed. The detailed error\nfollows.\n\n\"Undefined symbols present after loading %s: %s\"\n(W) As the message says, some symbols stay undefined although the extension module was\ncorrectly loaded and initialised. The list of undefined symbols follows.\n",
            "subsections": []
        },
        "LIMITATIONS": {
            "content": "To reduce the overhead as much as possible, only one possible location is checked to find the\nextension DLL (this location is where \"make install\" would put the DLL). If not found, the\nsearch for the DLL is transparently delegated to \"DynaLoader\", which looks for the DLL along the\n@INC list.\n\nIn particular, this is applicable to the structure of @INC used for testing not-yet-installed\nextensions. This means that running uninstalled extensions may have much more overhead than\nrunning the same extensions after \"make install\".\n",
            "subsections": []
        },
        "KNOWN BUGS": {
            "content": "The new simpler way to call XSLoader::load() with no arguments at all does not work on Perl\n5.8.4 and 5.8.5.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "Please report any bugs or feature requests via the perlbug(1) utility.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "DynaLoader\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Ilya Zakharevich originally extracted \"XSLoader\" from \"DynaLoader\".\n\nCPAN version is currently maintained by Sébastien Aperghis-Tramoni <sebastien@aperghis.net>.\n\nPrevious maintainer was Michael G Schwern <schwern@pobox.com>.\n\nCOPYRIGHT & LICENSE\nCopyright (C) 1990-2011 by Larry Wall and others.\n\nThis program is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
            "subsections": []
        }
    },
    "summary": "XSLoader - Dynamically load C libraries into Perl code",
    "flags": [],
    "examples": [],
    "see_also": []
}