{
    "mode": "perldoc",
    "parameter": "ExtUtils::Embed",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/ExtUtils%3A%3AEmbed/json",
    "generated": "2026-06-11T01:58:36Z",
    "synopsis": "perl -MExtUtils::Embed -e xsinit\nperl -MExtUtils::Embed -e ccopts\nperl -MExtUtils::Embed -e ldopts",
    "sections": {
        "NAME": {
            "content": "ExtUtils::Embed - Utilities for embedding Perl in C/C++ applications\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "perl -MExtUtils::Embed -e xsinit\nperl -MExtUtils::Embed -e ccopts\nperl -MExtUtils::Embed -e ldopts\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "\"ExtUtils::Embed\" provides utility functions for embedding a Perl interpreter and extensions in\nyour C/C++ applications. Typically, an application Makefile will invoke \"ExtUtils::Embed\"\nfunctions while building your application.\n\nNote that on Debian systems the libperl-dev package is required for compiling applications which\nembed an interpreter.\n\n@EXPORT\n\"ExtUtils::Embed\" exports the following functions:\n",
            "subsections": [
                {
                    "name": "xsinit",
                    "content": ""
                },
                {
                    "name": "xsi_body",
                    "content": ""
                }
            ]
        },
        "FUNCTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "xsinit",
                    "content": "Generate C/C++ code for the XS initializer function.\n\nWhen invoked as `perl -MExtUtils::Embed -e xsinit --` the following options are recognized:\n\n-o <output filename> (Defaults to perlxsi.c)\n\n-o STDOUT will print to STDOUT.\n\n-std (Write code for extensions that are linked with the current Perl.)\n\nAny additional arguments are expected to be names of modules to generate code for.\n\nWhen invoked with parameters the following are accepted and optional:\n\n\"xsinit($filename,$std,[@modules])\"\n\nWhere,\n\n$filename is equivalent to the -o option.\n\n$std is boolean, equivalent to the -std option.\n\n[@modules] is an array ref, same as additional arguments mentioned above.\n\nExamples\nperl -MExtUtils::Embed -e xsinit -- -o xsinit.c Socket\n\nThis will generate code with an \"xsinit\" function that glues the perl \"Socket::bootstrap\"\nfunction to the C \"bootSocket\" function and writes it to a file named xsinit.c.\n\nNote that DynaLoader is a special case where it must call \"bootDynaLoader\" directly.\n\nperl -MExtUtils::Embed -e xsinit\n\nThis will generate code for linking with \"DynaLoader\" and each static extension found in\n$Config{staticext}. The code is written to the default file name perlxsi.c.\n\nperl -MExtUtils::Embed -e xsinit -- -o xsinit.c \\\n-std DBI DBD::Oracle\n\nHere, code is written for all the currently linked extensions along with code for \"DBI\" and\n\"DBD::Oracle\".\n\nIf you have a working \"DynaLoader\" then there is rarely any need to statically link in any\nother extensions.\n"
                },
                {
                    "name": "ldopts",
                    "content": "Output arguments for linking the Perl library and extensions to your application.\n\nWhen invoked as `perl -MExtUtils::Embed -e ldopts --` the following options are recognized:\n"
                },
                {
                    "name": "-std",
                    "content": "Output arguments for linking the Perl library and any extensions linked with the current\nPerl.\n"
                },
                {
                    "name": "-I <path1:path2>",
                    "content": "Search path for ModuleName.a archives. Default path is @INC. Library archives are expected\nto be found as /some/path/auto/ModuleName/ModuleName.a For example, when looking for\nSocket.a relative to a search path, we should find auto/Socket/Socket.a\n\nWhen looking for \"DBD::Oracle\" relative to a search path, we should find\nauto/DBD/Oracle/Oracle.a\n\nKeep in mind that you can always supply /my/own/path/ModuleName.a as an additional linker\nargument.\n\n-- <list of linker args>\n\nAdditional linker arguments to be considered.\n\nAny additional arguments found before the -- token are expected to be names of modules to\ngenerate code for.\n\nWhen invoked with parameters the following are accepted and optional:\n\n\"ldopts($std,[@modules],[@linkargs],$path)\"\n\nWhere:\n\n$std is boolean, equivalent to the -std option.\n\n[@modules] is equivalent to additional arguments found before the -- token.\n\n[@linkargs] is equivalent to arguments found after the -- token.\n\n$path is equivalent to the -I option.\n\nIn addition, when ldopts is called with parameters, it will return the argument string\nrather than print it to STDOUT.\n\nExamples\nperl -MExtUtils::Embed -e ldopts\n\nThis will print arguments for linking with \"libperl\" and extensions found in\n$Config{staticext}. This includes libraries found in $Config{libs} and the first\nModuleName.a library for each extension that is found by searching @INC or the path\nspecified by the -I option. In addition, when ModuleName.a is found, additional linker\narguments are picked up from the extralibs.ld file in the same directory.\n\nperl -MExtUtils::Embed -e ldopts -- -std Socket\n\nThis will do the same as the above example, along with printing additional arguments for\nlinking with the \"Socket\" extension.\n\nperl -MExtUtils::Embed -e ldopts -- -std Msql -- \\\n-L/usr/msql/lib -lmsql\n\nAny arguments after the second '--' token are additional linker arguments that will be\nexamined for potential conflict. If there is no conflict, the additional arguments will be\npart of the output.\n",
                    "flag": "-I",
                    "arg": "<path1:path2>"
                },
                {
                    "name": "perl_inc",
                    "content": "For including perl header files this function simply prints:\n\n-I$Config{archlibexp}/CORE\n\nSo, rather than having to say:\n\nperl -MConfig -e 'print \"-I$Config{archlibexp}/CORE\"'\n\nJust say:\n\nperl -MExtUtils::Embed -e perlinc\n"
                },
                {
                    "name": "ccflags",
                    "content": "These functions simply print $Config{ccflags} and $Config{ccdlflags}\n"
                },
                {
                    "name": "ccopts",
                    "content": "This function combines \"perlinc()\", \"ccflags()\" and \"ccdlflags()\" into one.\n"
                },
                {
                    "name": "xsi_header",
                    "content": "This function simply returns a string defining the same \"EXTERNC\" macro as perlmain.c along\nwith #including perl.h and EXTERN.h.\n"
                },
                {
                    "name": "xsi_protos",
                    "content": "This function returns a string of \"boot$ModuleName\" prototypes for each @modules.\n"
                },
                {
                    "name": "xsi_body",
                    "content": "This function returns a string of calls to \"newXS()\" that glue the module *bootstrap*\nfunction to *bootModuleName* for each @modules.\n\n\"xsinit()\" uses the xsi* functions to generate most of its code.\n"
                }
            ]
        },
        "EXAMPLES": {
            "content": "For examples on how to use \"ExtUtils::Embed\" for building C/C++ applications with embedded perl,\nsee perlembed.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "perlembed\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Doug MacEachern <\"dougm@osf.org\">\n\nBased on ideas from Tim Bunce <\"Tim.Bunce@ig.co.uk\"> and minimod.pl by Andreas Koenig\n<\"k@anna.in-berlin.de\"> and Tim Bunce.\n",
            "subsections": []
        }
    },
    "summary": "ExtUtils::Embed - Utilities for embedding Perl in C/C++ applications",
    "flags": [],
    "examples": [
        "For examples on how to use \"ExtUtils::Embed\" for building C/C++ applications with embedded perl,",
        "see perlembed."
    ],
    "see_also": []
}