SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG
DONATE


YUM REPOSITORY

 
 

MAN page from CentOS 6 local-perl-ExtUtils-CBuilder-0.280203-162.2.noarch.rpm

ExtUtils::CBuilder

Section: Perl Programmers Reference Guide (3pm)
Updated: 2011-06-20
Index 

NAME

ExtUtils::CBuilder - Compile and link C code for Perl modules 

SYNOPSIS

  use ExtUtils::CBuilder;  my $b = ExtUtils::CBuilder->new(%options);  $obj_file = $b->compile(source => 'MyModule.c');  $lib_file = $b->link(objects => $obj_file);
 

DESCRIPTION

This module can build the C portions of Perl modules by invoking theappropriate compilers and linkers in a cross-platform manner. It wasmotivated by the "Module::Build" project, but may be useful for otherpurposes as well. However, it is not intended as a generalcross-platform interface to all your C building needs. That wouldhave been a much more ambitious goal! 

METHODS

new
Returns a new "ExtUtils::CBuilder" object. A "config" parameterlets you override "Config.pm" settings for all operations performedby the object, as in the following example:

  # Use a different compiler than Config.pm says  my $b = ExtUtils::CBuilder->new( config =>                                   { ld => 'gcc' } );

A "quiet" parameter tells "CBuilder" to not print its "system()"commands before executing them:

  # Be quieter than normal  my $b = ExtUtils::CBuilder->new( quiet => 1 );
have_compiler
Returns true if the current system has a working C compiler andlinker, false otherwise. To determine this, we actually compile andlink a sample C library. The sample will be compiled in the systemtempdir or, if that fails for some reason, in the current directory.
have_cplusplus
Just like have_compiler but for C++ instead of C.
compile
Compiles a C source file and produces an object file. The name of theobject file is returned. The source file is specified in a "source"parameter, which is required; the other parameters listed below areoptional.
object_file
Specifies the name of the output file to create. Otherwise the"object_file()" method will be consulted, passing it the name of the"source" file.
include_dirs
Specifies any additional directories in which to search for headerfiles. May be given as a string indicating a single directory, or asa list reference indicating multiple directories.
extra_compiler_flags
Specifies any additional arguments to pass to the compiler. Should begiven as a list reference containing the arguments individually, or ifthis is not possible, as a string containing all the argumentstogether.
C++
Specifies that the source file is a C++ source file and sets appropriatecompiler flags

The operation of this method is also affected by the"archlibexp", "cccdlflags", "ccflags", "optimize", and "cc"entries in "Config.pm".

link
Invokes the linker to produce a library file from object files. Inscalar context, the name of the library file is returned. In listcontext, the library file and any temporary files created arereturned. A required "objects" parameter contains the name of theobject files to process, either in a string (for one object file) orlist reference (for one or more files). The following parameters areoptional:
lib_file
Specifies the name of the output library file to create. Otherwisethe "lib_file()" method will be consulted, passing it the name ofthe first entry in "objects".
module_name
Specifies the name of the Perl module that will be created by linking.On platforms that need to do prelinking (Win32, OS/2, etc.) this is arequired parameter.
extra_linker_flags
Any additional flags you wish to pass to the linker.

On platforms where "need_prelink()" returns true, "prelink()"will be called automatically.

The operation of this method is also affected by the "lddlflags","shrpenv", and "ld" entries in "Config.pm".

link_executable
Invokes the linker to produce an executable file from object files. Inscalar context, the name of the executable file is returned. In listcontext, the executable file and any temporary files created arereturned. A required "objects" parameter contains the name of theobject files to process, either in a string (for one object file) orlist reference (for one or more files). The optional parameters arethe same as "link" with exception for
exe_file
Specifies the name of the output executable file to create. Otherwisethe "exe_file()" method will be consulted, passing it the name of thefirst entry in "objects".
object_file
 my $object_file = $b->object_file($source_file);

Converts the name of a C source file to the most natural name of anoutput object file to create from it. For instance, on Unix thesource file foo.c would result in the object file foo.o.

lib_file
 my $lib_file = $b->lib_file($object_file);

Converts the name of an object file to the most natural name of aoutput library file to create from it. For instance, on Mac OS X theobject file foo.o would result in the library file foo.bundle.

exe_file
 my $exe_file = $b->exe_file($object_file);

Converts the name of an object file to the most natural name of anexecutable file to create from it. For instance, on Mac OS X theobject file foo.o would result in the executable file foo, andon Windows it would result in foo.exe.

prelink
On certain platforms like Win32, OS/2, VMS, and AIX, it is necessaryto perform some actions before invoking the linker. The"ExtUtils::Mksymlists" module does this, writing files used by thelinker during the creation of shared libraries for dynamic extensions.The names of any files written will be returned as a list.

Several parameters correspond to "ExtUtils::Mksymlists::Mksymlists()"options, as follows:

    Mksymlists()   prelink()          type   -------------|-------------------|-------------------    NAME        |  dl_name          | string (required)    DLBASE      |  dl_base          | string    FILE        |  dl_file          | string    DL_VARS     |  dl_vars          | array reference    DL_FUNCS    |  dl_funcs         | hash reference    FUNCLIST    |  dl_func_list     | array reference    IMPORTS     |  dl_imports       | hash reference    VERSION     |  dl_version       | string

Please see the documentation for "ExtUtils::Mksymlists" for thedetails of what these parameters do.

need_prelink
Returns true on platforms where "prelink()" should be calledduring linking, and false otherwise.
extra_link_args_after_prelink
Returns list of extra arguments to give to the link command; the argumentsare the same as for prelink(), with addition of array reference to theresults of prelink(); this reference is indexed by key "prelink_res".
 

TO DO

Currently this has only been tested on Unix and doesn't contain any ofthe Windows-specific code from the "Module::Build" project. I'll dothat next. 

HISTORY

This module is an outgrowth of the "Module::Build" project, to whichthere have been many contributors. Notably, Randy W. Sims submittedlots of code to support 3 compilers on Windows and helped with variousother platform-specific issues. Ilya Zakharevich has contributedfixes for OS/2; John E. Malmberg and Peter Prymmer have done likewisefor VMS. 

AUTHOR

Ken Williams, kwilliamsAATTcpan.org 

COPYRIGHT

Copyright (c) 2003-2005 Ken Williams. All rights reserved.

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

SEE ALSO

perl(1), Module::Build(3)


 

Index

NAME
SYNOPSIS
DESCRIPTION
METHODS
TO DO
HISTORY
AUTHOR
COPYRIGHT
SEE ALSO

This document was created byman2html,using the manual pages.