Install Perl 5.8.8
[msysgit.git] / mingw / html / lib / ExtUtils / Liblist.html
blob455779e942dcc58c03c9f586e86b201d4515f498
1 <?xml version="1.0" ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>ExtUtils::Liblist - determine libraries to use and how to use them</title>
6 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7 <link rev="made" href="mailto:" />
8 </head>
10 <body style="background-color: white">
11 <table border="0" width="100%" cellspacing="0" cellpadding="3">
12 <tr><td class="block" style="background-color: #cccccc" valign="middle">
13 <big><strong><span class="block">&nbsp;ExtUtils::Liblist - determine libraries to use and how to use them</span></strong></big>
14 </td></tr>
15 </table>
17 <p><a name="__index__"></a></p>
18 <!-- INDEX BEGIN -->
20 <ul>
22 <li><a href="#name">NAME</a></li>
23 <li><a href="#synopsis">SYNOPSIS</a></li>
24 <li><a href="#description">DESCRIPTION</a></li>
25 <ul>
27 <li><a href="#extralibs">EXTRALIBS</a></li>
28 <li><a href="#ldloadlibs_and_ld_run_path">LDLOADLIBS and LD_RUN_PATH</a></li>
29 <li><a href="#bsloadlibs">BSLOADLIBS</a></li>
30 </ul>
32 <li><a href="#portability">PORTABILITY</a></li>
33 <ul>
35 <li><a href="#vms_implementation">VMS implementation</a></li>
36 <li><a href="#win32_implementation">Win32 implementation</a></li>
37 </ul>
39 <li><a href="#see_also">SEE ALSO</a></li>
40 </ul>
41 <!-- INDEX END -->
43 <hr />
44 <p>
45 </p>
46 <h1><a name="name">NAME</a></h1>
47 <p>ExtUtils::Liblist - determine libraries to use and how to use them</p>
48 <p>
49 </p>
50 <hr />
51 <h1><a name="synopsis">SYNOPSIS</a></h1>
52 <pre>
53 require ExtUtils::Liblist;</pre>
54 <pre>
55 $MM-&gt;ext($potential_libs, $verbose, $need_names);</pre>
56 <pre>
57 # Usually you can get away with:
58 ExtUtils::Liblist-&gt;ext($potential_libs, $verbose, $need_names)</pre>
59 <p>
60 </p>
61 <hr />
62 <h1><a name="description">DESCRIPTION</a></h1>
63 <p>This utility takes a list of libraries in the form <code>-llib1 -llib2
64 -llib3</code> and returns lines suitable for inclusion in an extension
65 Makefile. Extra library paths may be included with the form
66 <code>-L/another/path</code> this will affect the searches for all subsequent
67 libraries.</p>
68 <p>It returns an array of four or five scalar values: EXTRALIBS,
69 BSLOADLIBS, LDLOADLIBS, LD_RUN_PATH, and, optionally, a reference to
70 the array of the filenames of actual libraries. Some of these don't
71 mean anything unless on Unix. See the details about those platform
72 specifics below. The list of the filenames is returned only if
73 $need_names argument is true.</p>
74 <p>Dependent libraries can be linked in one of three ways:</p>
75 <ul>
76 <li><strong><a name="item_for_static_extensions">For static extensions</a></strong>
78 <p>by the ld command when the perl binary is linked with the extension
79 library. See EXTRALIBS below.</p>
80 </li>
81 <li><strong><a name="item_for_dynamic_extensions_at_build_2flink_time">For dynamic extensions at build/link time</a></strong>
83 <p>by the ld command when the shared object is built/linked. See
84 LDLOADLIBS below.</p>
85 </li>
86 <li><strong><a name="item_for_dynamic_extensions_at_load_time">For dynamic extensions at load time</a></strong>
88 <p>by the DynaLoader when the shared object is loaded. See BSLOADLIBS
89 below.</p>
90 </li>
91 </ul>
92 <p>
93 </p>
94 <h2><a name="extralibs">EXTRALIBS</a></h2>
95 <p>List of libraries that need to be linked with when linking a perl
96 binary which includes this extension. Only those libraries that
97 actually exist are included. These are written to a file and used
98 when linking perl.</p>
99 <p>
100 </p>
101 <h2><a name="ldloadlibs_and_ld_run_path">LDLOADLIBS and LD_RUN_PATH</a></h2>
102 <p>List of those libraries which can or must be linked into the shared
103 library when created using ld. These may be static or dynamic
104 libraries. LD_RUN_PATH is a colon separated list of the directories
105 in LDLOADLIBS. It is passed as an environment variable to the process
106 that links the shared library.</p>
108 </p>
109 <h2><a name="bsloadlibs">BSLOADLIBS</a></h2>
110 <p>List of those libraries that are needed but can be linked in
111 dynamically at run time on this platform. SunOS/Solaris does not need
112 this because ld records the information (from LDLOADLIBS) into the
113 object file. This list is used to create a .bs (bootstrap) file.</p>
115 </p>
116 <hr />
117 <h1><a name="portability">PORTABILITY</a></h1>
118 <p>This module deals with a lot of system dependencies and has quite a
119 few architecture specific <code>if</code>s in the code.</p>
121 </p>
122 <h2><a name="vms_implementation">VMS implementation</a></h2>
123 <p>The version of <code>ext()</code> which is executed under VMS differs from the
124 Unix-OS/2 version in several respects:</p>
125 <ul>
126 <li>
127 <p>Input library and path specifications are accepted with or without the
128 <code>-l</code> and <code>-L</code> prefixes used by Unix linkers. If neither prefix is
129 present, a token is considered a directory to search if it is in fact
130 a directory, and a library to search for otherwise. Authors who wish
131 their extensions to be portable to Unix or OS/2 should use the Unix
132 prefixes, since the Unix-OS/2 version of <code>ext()</code> requires them.</p>
133 </li>
134 <li>
135 <p>Wherever possible, shareable images are preferred to object libraries,
136 and object libraries to plain object files. In accordance with VMS
137 naming conventions, <code>ext()</code> looks for files named <em>lib</em>shr and <em>lib</em>rtl;
138 it also looks for <em>lib</em>lib and lib<em>lib</em> to accommodate Unix conventions
139 used in some ported software.</p>
140 </li>
141 <li>
142 <p>For each library that is found, an appropriate directive for a linker options
143 file is generated. The return values are space-separated strings of
144 these directives, rather than elements used on the linker command line.</p>
145 </li>
146 <li>
147 <p>LDLOADLIBS contains both the libraries found based on <code>$potential_libs</code> and
148 the CRTLs, if any, specified in Config.pm. EXTRALIBS contains just those
149 libraries found based on <code>$potential_libs</code>. BSLOADLIBS and LD_RUN_PATH
150 are always empty.</p>
151 </li>
152 </ul>
153 <p>In addition, an attempt is made to recognize several common Unix library
154 names, and filter them out or convert them to their VMS equivalents, as
155 appropriate.</p>
156 <p>In general, the VMS version of <code>ext()</code> should properly handle input from
157 extensions originally designed for a Unix or VMS environment. If you
158 encounter problems, or discover cases where the search could be improved,
159 please let us know.</p>
161 </p>
162 <h2><a name="win32_implementation">Win32 implementation</a></h2>
163 <p>The version of <code>ext()</code> which is executed under Win32 differs from the
164 Unix-OS/2 version in several respects:</p>
165 <ul>
166 <li>
167 <p>If <code>$potential_libs</code> is empty, the return value will be empty.
168 Otherwise, the libraries specified by <code>$Config{perllibs}</code> (see Config.pm)
169 will be appended to the list of <code>$potential_libs</code>. The libraries
170 will be searched for in the directories specified in <code>$potential_libs</code>,
171 <code>$Config{libpth}</code>, and in <code>$Config{installarchlib}/CORE</code>.
172 For each library that is found, a space-separated list of fully qualified
173 library pathnames is generated.</p>
174 </li>
175 <li>
176 <p>Input library and path specifications are accepted with or without the
177 <code>-l</code> and <code>-L</code> prefixes used by Unix linkers.</p>
178 <p>An entry of the form <code>-La:\foo</code> specifies the <code>a:\foo</code> directory to look
179 for the libraries that follow.</p>
180 <p>An entry of the form <code>-lfoo</code> specifies the library <code>foo</code>, which may be
181 spelled differently depending on what kind of compiler you are using. If
182 you are using GCC, it gets translated to <code>libfoo.a</code>, but for other win32
183 compilers, it becomes <code>foo.lib</code>. If no files are found by those translated
184 names, one more attempt is made to find them using either <code>foo.a</code> or
185 <code>libfoo.lib</code>, depending on whether GCC or some other win32 compiler is
186 being used, respectively.</p>
187 <p>If neither the <code>-L</code> or <code>-l</code> prefix is present in an entry, the entry is
188 considered a directory to search if it is in fact a directory, and a
189 library to search for otherwise. The <code>$Config{lib_ext}</code> suffix will
190 be appended to any entries that are not directories and don't already have
191 the suffix.</p>
192 <p>Note that the <code>-L</code> and <code>-l</code> prefixes are <strong>not required</strong>, but authors
193 who wish their extensions to be portable to Unix or OS/2 should use the
194 prefixes, since the Unix-OS/2 version of <code>ext()</code> requires them.</p>
195 </li>
196 <li>
197 <p>Entries cannot be plain object files, as many Win32 compilers will
198 not handle object files in the place of libraries.</p>
199 </li>
200 <li>
201 <p>Entries in <code>$potential_libs</code> beginning with a colon and followed by
202 alphanumeric characters are treated as flags. Unknown flags will be ignored.</p>
203 <p>An entry that matches <code>/:nodefault/i</code> disables the appending of default
204 libraries found in <code>$Config{perllibs}</code> (this should be only needed very rarely).</p>
205 <p>An entry that matches <code>/:nosearch/i</code> disables all searching for
206 the libraries specified after it. Translation of <code>-Lfoo</code> and
207 <code>-lfoo</code> still happens as appropriate (depending on compiler being used,
208 as reflected by <code>$Config{cc}</code>), but the entries are not verified to be
209 valid files or directories.</p>
210 <p>An entry that matches <code>/:search/i</code> reenables searching for
211 the libraries specified after it. You can put it at the end to
212 enable searching for default libraries specified by <code>$Config{perllibs}</code>.</p>
213 </li>
214 <li>
215 <p>The libraries specified may be a mixture of static libraries and
216 import libraries (to link with DLLs). Since both kinds are used
217 pretty transparently on the Win32 platform, we do not attempt to
218 distinguish between them.</p>
219 </li>
220 <li>
221 <p>LDLOADLIBS and EXTRALIBS are always identical under Win32, and BSLOADLIBS
222 and LD_RUN_PATH are always empty (this may change in future).</p>
223 </li>
224 <li>
225 <p>You must make sure that any paths and path components are properly
226 surrounded with double-quotes if they contain spaces. For example,
227 <code>$potential_libs</code> could be (literally):</p>
228 <pre>
229 &quot;-Lc:\Program Files\vc\lib&quot; msvcrt.lib &quot;la test\foo bar.lib&quot;</pre>
230 <p>Note how the first and last entries are protected by quotes in order
231 to protect the spaces.</p>
232 </li>
233 <li>
234 <p>Since this module is most often used only indirectly from extension
235 <code>Makefile.PL</code> files, here is an example <code>Makefile.PL</code> entry to add
236 a library to the build process for an extension:</p>
237 <pre>
238 LIBS =&gt; ['-lgl']</pre>
239 <p>When using GCC, that entry specifies that MakeMaker should first look
240 for <code>libgl.a</code> (followed by <code>gl.a</code>) in all the locations specified by
241 <code>$Config{libpth}</code>.</p>
242 <p>When using a compiler other than GCC, the above entry will search for
243 <code>gl.lib</code> (followed by <code>libgl.lib</code>).</p>
244 <p>If the library happens to be in a location not in <code>$Config{libpth}</code>,
245 you need:</p>
246 <pre>
247 LIBS =&gt; ['-Lc:\gllibs -lgl']</pre>
248 <p>Here is a less often used example:</p>
249 <pre>
250 LIBS =&gt; ['-lgl', ':nosearch -Ld:\mesalibs -lmesa -luser32']</pre>
251 <p>This specifies a search for library <code>gl</code> as before. If that search
252 fails to find the library, it looks at the next item in the list. The
253 <code>:nosearch</code> flag will prevent searching for the libraries that follow,
254 so it simply returns the value as <code>-Ld:\mesalibs -lmesa -luser32</code>,
255 since GCC can use that value as is with its linker.</p>
256 <p>When using the Visual C compiler, the second item is returned as
257 <code>-libpath:d:\mesalibs mesa.lib user32.lib</code>.</p>
258 <p>When using the Borland compiler, the second item is returned as
259 <code>-Ld:\mesalibs mesa.lib user32.lib</code>, and MakeMaker takes care of
260 moving the <code>-Ld:\mesalibs</code> to the correct place in the linker
261 command line.</p>
262 </li>
263 </ul>
265 </p>
266 <hr />
267 <h1><a name="see_also">SEE ALSO</a></h1>
268 <p><a href="file://C|\msysgit\mingw\html/lib/ExtUtils/MakeMaker.html">the ExtUtils::MakeMaker manpage</a></p>
269 <table border="0" width="100%" cellspacing="0" cellpadding="3">
270 <tr><td class="block" style="background-color: #cccccc" valign="middle">
271 <big><strong><span class="block">&nbsp;ExtUtils::Liblist - determine libraries to use and how to use them</span></strong></big>
272 </td></tr>
273 </table>
275 </body>
277 </html>