.\" -*- mode: troff; coding: utf-8 -*-
.\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
.ie n \{\
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
.    if \nF \{\
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{\
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "ExtUtils::Liblist 3p"
.TH ExtUtils::Liblist 3p 2023-09-25 "perl v5.38.0" "Perl Programmers Reference Guide"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH NAME
ExtUtils::Liblist \- determine libraries to use and how to use them
.SH SYNOPSIS
.IX Header "SYNOPSIS"
.Vb 1
\&  require ExtUtils::Liblist;
\&
\&  $MM\->ext($potential_libs, $verbose, $need_names);
\&
\&  # Usually you can get away with:
\&  ExtUtils::Liblist\->ext($potential_libs, $verbose, $need_names)
.Ve
.SH DESCRIPTION
.IX Header "DESCRIPTION"
This utility takes a list of libraries in the form \f(CW\*(C`\-llib1 \-llib2
\&\-llib3\*(C'\fR and returns lines suitable for inclusion in an extension
Makefile.  Extra library paths may be included with the form
\&\f(CW\*(C`\-L/another/path\*(C'\fR this will affect the searches for all subsequent
libraries.
.PP
It returns an array of four or five scalar values: EXTRALIBS,
BSLOADLIBS, LDLOADLIBS, LD_RUN_PATH, and, optionally, a reference to
the array of the filenames of actual libraries.  Some of these don't
mean anything unless on Unix.  See the details about those platform
specifics below.  The list of the filenames is returned only if
\&\f(CW$need_names\fR argument is true.
.PP
Dependent libraries can be linked in one of three ways:
.IP \(bu 2
For static extensions
.Sp
by the ld command when the perl binary is linked with the extension
library. See EXTRALIBS below.
.IP \(bu 2
For dynamic extensions at build/link time
.Sp
by the ld command when the shared object is built/linked. See
LDLOADLIBS below.
.IP \(bu 2
For dynamic extensions at load time
.Sp
by the DynaLoader when the shared object is loaded. See BSLOADLIBS
below.
.SS EXTRALIBS
.IX Subsection "EXTRALIBS"
List of libraries that need to be linked with when linking a perl
binary which includes this extension. Only those libraries that
actually exist are included.  These are written to a file and used
when linking perl.
.SS "LDLOADLIBS and LD_RUN_PATH"
.IX Subsection "LDLOADLIBS and LD_RUN_PATH"
List of those libraries which can or must be linked into the shared
library when created using ld. These may be static or dynamic
libraries.  LD_RUN_PATH is a colon separated list of the directories
in LDLOADLIBS. It is passed as an environment variable to the process
that links the shared library.
.SS BSLOADLIBS
.IX Subsection "BSLOADLIBS"
List of those libraries that are needed but can be linked in
dynamically at run time on this platform.  SunOS/Solaris does not need
this because ld records the information (from LDLOADLIBS) into the
object file.  This list is used to create a .bs (bootstrap) file.
.SH PORTABILITY
.IX Header "PORTABILITY"
This module deals with a lot of system dependencies and has quite a
few architecture specific \f(CW\*(C`if\*(C'\fRs in the code.
.SS "VMS implementation"
.IX Subsection "VMS implementation"
The version of \fBext()\fR which is executed under VMS differs from the
Unix\-OS/2 version in several respects:
.IP \(bu 2
Input library and path specifications are accepted with or without the
\&\f(CW\*(C`\-l\*(C'\fR and \f(CW\*(C`\-L\*(C'\fR prefixes used by Unix linkers.  If neither prefix is
present, a token is considered a directory to search if it is in fact
a directory, and a library to search for otherwise.  Authors who wish
their extensions to be portable to Unix or OS/2 should use the Unix
prefixes, since the Unix\-OS/2 version of \fBext()\fR requires them.
.IP \(bu 2
Wherever possible, shareable images are preferred to object libraries,
and object libraries to plain object files.  In accordance with VMS
naming conventions, \fBext()\fR looks for files named \fIlib\fRshr and \fIlib\fRrtl;
it also looks for \fIlib\fRlib and lib\fIlib\fR to accommodate Unix conventions
used in some ported software.
.IP \(bu 2
For each library that is found, an appropriate directive for a linker options
file is generated.  The return values are space-separated strings of
these directives, rather than elements used on the linker command line.
.IP \(bu 2
LDLOADLIBS contains both the libraries found based on \f(CW$potential_libs\fR and
the CRTLs, if any, specified in Config.pm.  EXTRALIBS contains just those
libraries found based on \f(CW$potential_libs\fR.  BSLOADLIBS and LD_RUN_PATH
are always empty.
.PP
In addition, an attempt is made to recognize several common Unix library
names, and filter them out or convert them to their VMS equivalents, as
appropriate.
.PP
In general, the VMS version of \fBext()\fR should properly handle input from
extensions originally designed for a Unix or VMS environment.  If you
encounter problems, or discover cases where the search could be improved,
please let us know.
.SS "Win32 implementation"
.IX Subsection "Win32 implementation"
The version of \fBext()\fR which is executed under Win32 differs from the
Unix\-OS/2 version in several respects:
.IP \(bu 2
If \f(CW$potential_libs\fR is empty, the return value will be empty.
Otherwise, the libraries specified by \f(CW$Config{perllibs}\fR (see Config.pm)
will be appended to the list of \f(CW$potential_libs\fR.  The libraries
will be searched for in the directories specified in \f(CW$potential_libs\fR,
\&\f(CW$Config{libpth}\fR, and in \f(CW\*(C`$Config{installarchlib}/CORE\*(C'\fR.
For each library that is found,  a space-separated list of fully qualified
library pathnames is generated.
.IP \(bu 2
Input library and path specifications are accepted with or without the
\&\f(CW\*(C`\-l\*(C'\fR and \f(CW\*(C`\-L\*(C'\fR prefixes used by Unix linkers.
.Sp
An entry of the form \f(CW\*(C`\-La:\efoo\*(C'\fR specifies the \f(CW\*(C`a:\efoo\*(C'\fR directory to look
for the libraries that follow.
.Sp
An entry of the form \f(CW\*(C`\-lfoo\*(C'\fR specifies the library \f(CW\*(C`foo\*(C'\fR, which may be
spelled differently depending on what kind of compiler you are using.  If
you are using GCC, it gets translated to \f(CW\*(C`libfoo.a\*(C'\fR, but for other win32
compilers, it becomes \f(CW\*(C`foo.lib\*(C'\fR.  If no files are found by those translated
names, one more attempt is made to find them using either \f(CW\*(C`foo.a\*(C'\fR or
\&\f(CW\*(C`libfoo.lib\*(C'\fR, depending on whether GCC or some other win32 compiler is
being used, respectively.
.Sp
If neither the \f(CW\*(C`\-L\*(C'\fR or \f(CW\*(C`\-l\*(C'\fR prefix is present in an entry, the entry is
considered a directory to search if it is in fact a directory, and a
library to search for otherwise.  The \f(CW$Config{lib_ext}\fR suffix will
be appended to any entries that are not directories and don't already have
the suffix.
.Sp
Note that the \f(CW\*(C`\-L\*(C'\fR and \f(CW\*(C`\-l\*(C'\fR prefixes are \fBnot required\fR, but authors
who wish their extensions to be portable to Unix or OS/2 should use the
prefixes, since the Unix\-OS/2 version of \fBext()\fR requires them.
.IP \(bu 2
Entries cannot be plain object files, as many Win32 compilers will
not handle object files in the place of libraries.
.IP \(bu 2
Entries in \f(CW$potential_libs\fR beginning with a colon and followed by
alphanumeric characters are treated as flags.  Unknown flags will be ignored.
.Sp
An entry that matches \f(CW\*(C`/:nodefault/i\*(C'\fR disables the appending of default
libraries found in \f(CW$Config{perllibs}\fR (this should be only needed very rarely).
.Sp
An entry that matches \f(CW\*(C`/:nosearch/i\*(C'\fR disables all searching for
the libraries specified after it.  Translation of \f(CW\*(C`\-Lfoo\*(C'\fR and
\&\f(CW\*(C`\-lfoo\*(C'\fR still happens as appropriate (depending on compiler being used,
as reflected by \f(CW$Config{cc}\fR), but the entries are not verified to be
valid files or directories.
.Sp
An entry that matches \f(CW\*(C`/:search/i\*(C'\fR reenables searching for
the libraries specified after it.  You can put it at the end to
enable searching for default libraries specified by \f(CW$Config{perllibs}\fR.
.IP \(bu 2
The libraries specified may be a mixture of static libraries and
import libraries (to link with DLLs).  Since both kinds are used
pretty transparently on the Win32 platform, we do not attempt to
distinguish between them.
.IP \(bu 2
LDLOADLIBS and EXTRALIBS are always identical under Win32, and BSLOADLIBS
and LD_RUN_PATH are always empty (this may change in future).
.IP \(bu 2
You must make sure that any paths and path components are properly
surrounded with double-quotes if they contain spaces. For example,
\&\f(CW$potential_libs\fR could be (literally):
.Sp
.Vb 1
\&        "\-Lc:\eProgram Files\evc\elib" msvcrt.lib "la test\efoo bar.lib"
.Ve
.Sp
Note how the first and last entries are protected by quotes in order
to protect the spaces.
.IP \(bu 2
Since this module is most often used only indirectly from extension
\&\f(CW\*(C`Makefile.PL\*(C'\fR files, here is an example \f(CW\*(C`Makefile.PL\*(C'\fR entry to add
a library to the build process for an extension:
.Sp
.Vb 1
\&        LIBS => [\*(Aq\-lgl\*(Aq]
.Ve
.Sp
When using GCC, that entry specifies that MakeMaker should first look
for \f(CW\*(C`libgl.a\*(C'\fR (followed by \f(CW\*(C`gl.a\*(C'\fR) in all the locations specified by
\&\f(CW$Config{libpth}\fR.
.Sp
When using a compiler other than GCC, the above entry will search for
\&\f(CW\*(C`gl.lib\*(C'\fR (followed by \f(CW\*(C`libgl.lib\*(C'\fR).
.Sp
If the library happens to be in a location not in \f(CW$Config{libpth}\fR,
you need:
.Sp
.Vb 1
\&        LIBS => [\*(Aq\-Lc:\egllibs \-lgl\*(Aq]
.Ve
.Sp
Here is a less often used example:
.Sp
.Vb 1
\&        LIBS => [\*(Aq\-lgl\*(Aq, \*(Aq:nosearch \-Ld:\emesalibs \-lmesa \-luser32\*(Aq]
.Ve
.Sp
This specifies a search for library \f(CW\*(C`gl\*(C'\fR as before.  If that search
fails to find the library, it looks at the next item in the list. The
\&\f(CW\*(C`:nosearch\*(C'\fR flag will prevent searching for the libraries that follow,
so it simply returns the value as \f(CW\*(C`\-Ld:\emesalibs \-lmesa \-luser32\*(C'\fR,
since GCC can use that value as is with its linker.
.Sp
When using the Visual C compiler, the second item is returned as
\&\f(CW\*(C`\-libpath:d:\emesalibs mesa.lib user32.lib\*(C'\fR.
.Sp
When using the Borland compiler, the second item is returned as
\&\f(CW\*(C`\-Ld:\emesalibs mesa.lib user32.lib\*(C'\fR, and MakeMaker takes care of
moving the \f(CW\*(C`\-Ld:\emesalibs\*(C'\fR to the correct place in the linker
command line.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
ExtUtils::MakeMaker
