{
    "content": [
        {
            "type": "text",
            "text": "# ExtUtils::CBuilder (perldoc)\n\n**Summary:** ExtUtils::CBuilder - Compile and link C code for Perl modules\n\n**Synopsis:** use ExtUtils::CBuilder;\nmy $b = ExtUtils::CBuilder->new(%options);\n$objfile = $b->compile(source => 'MyModule.c');\n$libfile = $b->link(objects => $objfile);\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **SYNOPSIS** (6 lines)\n- **DESCRIPTION** (5 lines)\n- **METHODS** (133 lines)\n- **TO DO** (3 lines)\n- **HISTORY** (5 lines)\n- **SUPPORT** (7 lines)\n- **AUTHOR** (4 lines)\n- **COPYRIGHT** (5 lines)\n- **SEE ALSO** (1 lines) — 1 subsections\n  - perl (1 lines)\n\n## Full Content\n\n### NAME\n\nExtUtils::CBuilder - Compile and link C code for Perl modules\n\n### SYNOPSIS\n\nuse ExtUtils::CBuilder;\n\nmy $b = ExtUtils::CBuilder->new(%options);\n$objfile = $b->compile(source => 'MyModule.c');\n$libfile = $b->link(objects => $objfile);\n\n### DESCRIPTION\n\nThis module can build the C portions of Perl modules by invoking the appropriate compilers and\nlinkers in a cross-platform manner. It was motivated by the \"Module::Build\" project, but may be\nuseful for other purposes as well. However, it is *not* intended as a general cross-platform\ninterface to all your C building needs. That would have been a much more ambitious goal!\n\n### METHODS\n\nnew Returns a new \"ExtUtils::CBuilder\" object. A \"config\" parameter lets you override\n\"Config.pm\" settings for all operations performed by the object, as in the following\nexample:\n\n# Use a different compiler than Config.pm says\nmy $b = ExtUtils::CBuilder->new( config =>\n{ ld => 'gcc' } );\n\nA \"quiet\" parameter tells \"CBuilder\" to not print its \"system()\" commands before executing\nthem:\n\n# Be quieter than normal\nmy $b = ExtUtils::CBuilder->new( quiet => 1 );\n\nhavecompiler\nReturns true if the current system has a working C compiler and linker, false otherwise. To\ndetermine this, we actually compile and link a sample C library. The sample will be compiled\nin the system tempdir or, if that fails for some reason, in the current directory.\n\nhavecplusplus\nJust like havecompiler but for C++ instead of C.\n\ncompile\nCompiles a C source file and produces an object file. The name of the object file is\nreturned. The source file is specified in a \"source\" parameter, which is required; the other\nparameters listed below are optional.\n\n\"objectfile\"\nSpecifies the name of the output file to create. Otherwise the \"objectfile()\" method\nwill be consulted, passing it the name of the \"source\" file.\n\n\"includedirs\"\nSpecifies any additional directories in which to search for header files. May be given\nas a string indicating a single directory, or as a list reference indicating multiple\ndirectories.\n\n\"extracompilerflags\"\nSpecifies any additional arguments to pass to the compiler. Should be given as a list\nreference containing the arguments individually, or if this is not possible, as a string\ncontaining all the arguments together.\n\n\"C++\"\nSpecifies that the source file is a C++ source file and sets appropriate compiler flags\n\nThe operation of this method is also affected by the \"archlibexp\", \"cccdlflags\", \"ccflags\",\n\"optimize\", and \"cc\" entries in \"Config.pm\".\n\nlink\nInvokes the linker to produce a library file from object files. In scalar context, the name\nof the library file is returned. In list context, the library file and any temporary files\ncreated are returned. A required \"objects\" parameter contains the name of the object files\nto process, either in a string (for one object file) or list reference (for one or more\nfiles). The following parameters are optional:\n\nlibfile\nSpecifies the name of the output library file to create. Otherwise the \"libfile()\"\nmethod will be consulted, passing it the name of the first entry in \"objects\".\n\nmodulename\nSpecifies the name of the Perl module that will be created by linking. On platforms that\nneed to do prelinking (Win32, OS/2, etc.) this is a required parameter.\n\nextralinkerflags\nAny additional flags you wish to pass to the linker.\n\nOn platforms where \"needprelink()\" returns true, \"prelink()\" will be called automatically.\n\nThe operation of this method is also affected by the \"lddlflags\", \"shrpenv\", and \"ld\"\nentries in \"Config.pm\".\n\nlinkexecutable\nInvokes the linker to produce an executable file from object files. In scalar context, the\nname of the executable file is returned. In list context, the executable file and any\ntemporary files created are returned. A required \"objects\" parameter contains the name of\nthe object files to process, either in a string (for one object file) or list reference (for\none or more files). The optional parameters are the same as \"link\" with exception for\n\nexefile\nSpecifies the name of the output executable file to create. Otherwise the \"exefile()\"\nmethod will be consulted, passing it the name of the first entry in \"objects\".\n\nobjectfile\nmy $objectfile = $b->objectfile($sourcefile);\n\nConverts the name of a C source file to the most natural name of an output object file to\ncreate from it. For instance, on Unix the source file foo.c would result in the object file\nfoo.o.\n\nlibfile\nmy $libfile = $b->libfile($objectfile);\n\nConverts the name of an object file to the most natural name of a output library file to\ncreate from it. For instance, on Mac OS X the object file foo.o would result in the library\nfile foo.bundle.\n\nexefile\nmy $exefile = $b->exefile($objectfile);\n\nConverts the name of an object file to the most natural name of an executable file to create\nfrom it. For instance, on Mac OS X the object file foo.o would result in the executable file\nfoo, and on Windows it would result in foo.exe.\n\nprelink\nOn certain platforms like Win32, OS/2, VMS, and AIX, it is necessary to perform some actions\nbefore invoking the linker. The \"ExtUtils::Mksymlists\" module does this, writing files used\nby the linker during the creation of shared libraries for dynamic extensions. The names of\nany files written will be returned as a list.\n\nSeveral parameters correspond to \"ExtUtils::Mksymlists::Mksymlists()\" options, as follows:\n\nMksymlists()   prelink()          type\n-------------|-------------------|-------------------\nNAME        |  dlname          | string (required)\nDLBASE      |  dlbase          | string\nFILE        |  dlfile          | string\nDLVARS     |  dlvars          | array reference\nDLFUNCS    |  dlfuncs         | hash reference\nFUNCLIST    |  dlfunclist     | array reference\nIMPORTS     |  dlimports       | hash reference\nVERSION     |  dlversion       | string\n\nPlease see the documentation for \"ExtUtils::Mksymlists\" for the details of what these\nparameters do.\n\nneedprelink\nReturns true on platforms where \"prelink()\" should be called during linking, and false\notherwise.\n\nextralinkargsafterprelink\nReturns list of extra arguments to give to the link command; the arguments are the same as\nfor prelink(), with addition of array reference to the results of prelink(); this reference\nis indexed by key \"prelinkres\".\n\n### TO DO\n\nCurrently this has only been tested on Unix and doesn't contain any of the Windows-specific code\nfrom the \"Module::Build\" project. I'll do that next.\n\n### HISTORY\n\nThis module is an outgrowth of the \"Module::Build\" project, to which there have been many\ncontributors. Notably, Randy W. Sims submitted lots of code to support 3 compilers on Windows\nand helped with various other platform-specific issues. Ilya Zakharevich has contributed fixes\nfor OS/2; John E. Malmberg and Peter Prymmer have done likewise for VMS.\n\n### SUPPORT\n\nExtUtils::CBuilder is maintained as part of the Perl 5 core. Please submit any bug reports via\nthe perlbug tool included with Perl 5. Bug reports will be included in the Perl 5 ticket system\nat <https://rt.perl.org>.\n\nThe Perl 5 source code is available at <https://perl5.git.perl.org/perl.git> and\nExtUtils-CBuilder may be found in the dist/ExtUtils-CBuilder directory of the repository.\n\n### AUTHOR\n\nKen Williams, kwilliams@cpan.org\n\nAdditional contributions by The Perl 5 Porters.\n\n### COPYRIGHT\n\nCopyright (c) 2003-2005 Ken Williams. All rights reserved.\n\nThis library is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n\n### SEE ALSO\n\n#### perl\n\n"
        }
    ],
    "structuredContent": {
        "command": "ExtUtils::CBuilder",
        "section": "",
        "mode": "perldoc",
        "summary": "ExtUtils::CBuilder - Compile and link C code for Perl modules",
        "synopsis": "use ExtUtils::CBuilder;\nmy $b = ExtUtils::CBuilder->new(%options);\n$objfile = $b->compile(source => 'MyModule.c');\n$libfile = $b->link(objects => $objfile);",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 133,
                "subsections": []
            },
            {
                "name": "TO DO",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "HISTORY",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "SUPPORT",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 1,
                "subsections": [
                    {
                        "name": "perl",
                        "lines": 1
                    }
                ]
            }
        ]
    }
}