Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 |
2 | .\" | |
3 | .\" Standard preamble: | |
4 | .\" ======================================================================== | |
5 | .de Sh \" Subsection heading | |
6 | .br | |
7 | .if t .Sp | |
8 | .ne 5 | |
9 | .PP | |
10 | \fB\\$1\fR | |
11 | .PP | |
12 | .. | |
13 | .de Sp \" Vertical space (when we can't use .PP) | |
14 | .if t .sp .5v | |
15 | .if n .sp | |
16 | .. | |
17 | .de Vb \" Begin verbatim text | |
18 | .ft CW | |
19 | .nf | |
20 | .ne \\$1 | |
21 | .. | |
22 | .de Ve \" End verbatim text | |
23 | .ft R | |
24 | .fi | |
25 | .. | |
26 | .\" Set up some character translations and predefined strings. \*(-- will | |
27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left | |
28 | .\" double quote, and \*(R" will give a right double quote. | will give a | |
29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to | |
30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' | |
31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. | |
32 | .tr \(*W-|\(bv\*(Tr | |
33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' | |
34 | .ie n \{\ | |
35 | . ds -- \(*W- | |
36 | . ds PI pi | |
37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch | |
38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch | |
39 | . ds L" "" | |
40 | . ds R" "" | |
41 | . ds C` "" | |
42 | . ds C' "" | |
43 | 'br\} | |
44 | .el\{\ | |
45 | . ds -- \|\(em\| | |
46 | . ds PI \(*p | |
47 | . ds L" `` | |
48 | . ds R" '' | |
49 | 'br\} | |
50 | .\" | |
51 | .\" If the F register is turned on, we'll generate index entries on stderr for | |
52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index | |
53 | .\" entries marked with X<> in POD. Of course, you'll have to process the | |
54 | .\" output yourself in some meaningful fashion. | |
55 | .if \nF \{\ | |
56 | . de IX | |
57 | . tm Index:\\$1\t\\n%\t"\\$2" | |
58 | .. | |
59 | . nr % 0 | |
60 | . rr F | |
61 | .\} | |
62 | .\" | |
63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes | |
64 | .\" way too many mistakes in technical documents. | |
65 | .hy 0 | |
66 | .if n .na | |
67 | .\" | |
68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). | |
69 | .\" Fear. Run. Save yourself. No user-serviceable parts. | |
70 | . \" fudge factors for nroff and troff | |
71 | .if n \{\ | |
72 | . ds #H 0 | |
73 | . ds #V .8m | |
74 | . ds #F .3m | |
75 | . ds #[ \f1 | |
76 | . ds #] \fP | |
77 | .\} | |
78 | .if t \{\ | |
79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) | |
80 | . ds #V .6m | |
81 | . ds #F 0 | |
82 | . ds #[ \& | |
83 | . ds #] \& | |
84 | .\} | |
85 | . \" simple accents for nroff and troff | |
86 | .if n \{\ | |
87 | . ds ' \& | |
88 | . ds ` \& | |
89 | . ds ^ \& | |
90 | . ds , \& | |
91 | . ds ~ ~ | |
92 | . ds / | |
93 | .\} | |
94 | .if t \{\ | |
95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" | |
96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' | |
97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' | |
98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' | |
99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' | |
100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' | |
101 | .\} | |
102 | . \" troff and (daisy-wheel) nroff accents | |
103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' | |
104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' | |
105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] | |
106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' | |
107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' | |
108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] | |
109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] | |
110 | .ds ae a\h'-(\w'a'u*4/10)'e | |
111 | .ds Ae A\h'-(\w'A'u*4/10)'E | |
112 | . \" corrections for vroff | |
113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' | |
114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' | |
115 | . \" for low resolution devices (crt and lpr) | |
116 | .if \n(.H>23 .if \n(.V>19 \ | |
117 | \{\ | |
118 | . ds : e | |
119 | . ds 8 ss | |
120 | . ds o a | |
121 | . ds d- d\h'-1'\(ga | |
122 | . ds D- D\h'-1'\(hy | |
123 | . ds th \o'bp' | |
124 | . ds Th \o'LP' | |
125 | . ds ae ae | |
126 | . ds Ae AE | |
127 | .\} | |
128 | .rm #[ #] #H #V #F C | |
129 | .\" ======================================================================== | |
130 | .\" | |
131 | .IX Title "XSLoader 3" | |
132 | .TH XSLoader 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide" | |
133 | .SH "NAME" | |
134 | XSLoader \- Dynamically load C libraries into Perl code | |
135 | .SH "VERSION" | |
136 | .IX Header "VERSION" | |
137 | Version 0.06 | |
138 | .SH "SYNOPSIS" | |
139 | .IX Header "SYNOPSIS" | |
140 | .Vb 2 | |
141 | \& package YourPackage; | |
142 | \& use XSLoader; | |
143 | .Ve | |
144 | .PP | |
145 | .Vb 1 | |
146 | \& XSLoader::load 'YourPackage', $YourPackage::VERSION; | |
147 | .Ve | |
148 | .SH "DESCRIPTION" | |
149 | .IX Header "DESCRIPTION" | |
150 | This module defines a standard \fIsimplified\fR interface to the dynamic | |
151 | linking mechanisms available on many platforms. Its primary purpose is | |
152 | to implement cheap automatic dynamic loading of Perl modules. | |
153 | .PP | |
154 | For a more complicated interface, see DynaLoader. Many (most) | |
155 | features of \f(CW\*(C`DynaLoader\*(C'\fR are not implemented in \f(CW\*(C`XSLoader\*(C'\fR, like for | |
156 | example the \f(CW\*(C`dl_load_flags\*(C'\fR, not honored by \f(CW\*(C`XSLoader\*(C'\fR. | |
157 | .ie n .Sh "Migration from ""DynaLoader""" | |
158 | .el .Sh "Migration from \f(CWDynaLoader\fP" | |
159 | .IX Subsection "Migration from DynaLoader" | |
160 | A typical module using DynaLoader starts like this: | |
161 | .PP | |
162 | .Vb 2 | |
163 | \& package YourPackage; | |
164 | \& require DynaLoader; | |
165 | .Ve | |
166 | .PP | |
167 | .Vb 3 | |
168 | \& our @ISA = qw( OnePackage OtherPackage DynaLoader ); | |
169 | \& our $VERSION = '0.01'; | |
170 | \& bootstrap YourPackage $VERSION; | |
171 | .Ve | |
172 | .PP | |
173 | Change this to | |
174 | .PP | |
175 | .Vb 2 | |
176 | \& package YourPackage; | |
177 | \& use XSLoader; | |
178 | .Ve | |
179 | .PP | |
180 | .Vb 3 | |
181 | \& our @ISA = qw( OnePackage OtherPackage ); | |
182 | \& our $VERSION = '0.01'; | |
183 | \& XSLoader::load 'YourPackage', $VERSION; | |
184 | .Ve | |
185 | .PP | |
186 | In other words: replace \f(CW\*(C`require DynaLoader\*(C'\fR by \f(CW\*(C`use XSLoader\*(C'\fR, remove | |
187 | \&\f(CW\*(C`DynaLoader\*(C'\fR from \f(CW@ISA\fR, change \f(CW\*(C`bootstrap\*(C'\fR by \f(CW\*(C`XSLoader::load\*(C'\fR. Do not | |
188 | forget to quote the name of your package on the \f(CW\*(C`XSLoader::load\*(C'\fR line, | |
189 | and add comma (\f(CW\*(C`,\*(C'\fR) before the arguments (\f(CW$VERSION\fR above). | |
190 | .PP | |
191 | Of course, if \f(CW@ISA\fR contained only \f(CW\*(C`DynaLoader\*(C'\fR, there is no need to have | |
192 | the \f(CW@ISA\fR assignment at all; moreover, if instead of \f(CW\*(C`our\*(C'\fR one uses the | |
193 | more backward-compatible | |
194 | .PP | |
195 | .Vb 1 | |
196 | \& use vars qw($VERSION @ISA); | |
197 | .Ve | |
198 | .PP | |
199 | one can remove this reference to \f(CW@ISA\fR together with the \f(CW@ISA\fR assignment. | |
200 | .PP | |
201 | If no \f(CW$VERSION\fR was specified on the \f(CW\*(C`bootstrap\*(C'\fR line, the last line becomes | |
202 | .PP | |
203 | .Vb 1 | |
204 | \& XSLoader::load 'YourPackage'; | |
205 | .Ve | |
206 | .Sh "Backward compatible boilerplate" | |
207 | .IX Subsection "Backward compatible boilerplate" | |
208 | If you want to have your cake and eat it too, you need a more complicated | |
209 | boilerplate. | |
210 | .PP | |
211 | .Vb 2 | |
212 | \& package YourPackage; | |
213 | \& use vars qw($VERSION @ISA); | |
214 | .Ve | |
215 | .PP | |
216 | .Vb 11 | |
217 | \& @ISA = qw( OnePackage OtherPackage ); | |
218 | \& $VERSION = '0.01'; | |
219 | \& eval { | |
220 | \& require XSLoader; | |
221 | \& XSLoader::load('YourPackage', $VERSION); | |
222 | \& 1; | |
223 | \& } or do { | |
224 | \& require DynaLoader; | |
225 | \& push @ISA, 'DynaLoader'; | |
226 | \& bootstrap YourPackage $VERSION; | |
227 | \& }; | |
228 | .Ve | |
229 | .PP | |
230 | The parentheses about \f(CW\*(C`XSLoader::load()\*(C'\fR arguments are needed since we replaced | |
231 | \&\f(CW\*(C`use XSLoader\*(C'\fR by \f(CW\*(C`require\*(C'\fR, so the compiler does not know that a function | |
232 | \&\f(CW\*(C`XSLoader::load()\*(C'\fR is present. | |
233 | .PP | |
234 | This boilerplate uses the low-overhead \f(CW\*(C`XSLoader\*(C'\fR if present; if used with | |
235 | an antic Perl which has no \f(CW\*(C`XSLoader\*(C'\fR, it falls back to using \f(CW\*(C`DynaLoader\*(C'\fR. | |
236 | .SH "Order of initialization: early \fIload()\fP" | |
237 | .IX Header "Order of initialization: early load()" | |
238 | \&\fISkip this section if the \s-1XSUB\s0 functions are supposed to be called from other | |
239 | modules only; read it only if you call your XSUBs from the code in your module, | |
240 | or have a \f(CI\*(C`BOOT:\*(C'\fI section in your \s-1XS\s0 file (see \*(L"The \s-1BOOT:\s0 Keyword\*(R" in perlxs). | |
241 | What is described here is equally applicable to the DynaLoader | |
242 | interface.\fR | |
243 | .PP | |
244 | A sufficiently complicated module using \s-1XS\s0 would have both Perl code (defined | |
245 | in \fIYourPackage.pm\fR) and \s-1XS\s0 code (defined in \fIYourPackage.xs\fR). If this | |
246 | Perl code makes calls into this \s-1XS\s0 code, and/or this \s-1XS\s0 code makes calls to | |
247 | the Perl code, one should be careful with the order of initialization. | |
248 | .PP | |
249 | The call to \f(CW\*(C`XSLoader::load()\*(C'\fR (or \f(CW\*(C`bootstrap()\*(C'\fR) has three side effects: | |
250 | .IP "\(bu" 4 | |
251 | if \f(CW$VERSION\fR was specified, a sanity check is done to ensure that the | |
252 | versions of the \fI.pm\fR and the (compiled) \fI.xs\fR parts are compatible; | |
253 | .IP "\(bu" 4 | |
254 | the XSUBs are made accessible from Perl; | |
255 | .IP "\(bu" 4 | |
256 | if a \f(CW\*(C`BOOT:\*(C'\fR section was present in the \fI.xs\fR file, the code there is called. | |
257 | .PP | |
258 | Consequently, if the code in the \fI.pm\fR file makes calls to these XSUBs, it is | |
259 | convenient to have XSUBs installed before the Perl code is defined; for | |
260 | example, this makes prototypes for XSUBs visible to this Perl code. | |
261 | Alternatively, if the \f(CW\*(C`BOOT:\*(C'\fR section makes calls to Perl functions (or | |
262 | uses Perl variables) defined in the \fI.pm\fR file, they must be defined prior to | |
263 | the call to \f(CW\*(C`XSLoader::load()\*(C'\fR (or \f(CW\*(C`bootstrap()\*(C'\fR). | |
264 | .PP | |
265 | The first situation being much more frequent, it makes sense to rewrite the | |
266 | boilerplate as | |
267 | .PP | |
268 | .Vb 3 | |
269 | \& package YourPackage; | |
270 | \& use XSLoader; | |
271 | \& use vars qw($VERSION @ISA); | |
272 | .Ve | |
273 | .PP | |
274 | .Vb 3 | |
275 | \& BEGIN { | |
276 | \& @ISA = qw( OnePackage OtherPackage ); | |
277 | \& $VERSION = '0.01'; | |
278 | .Ve | |
279 | .PP | |
280 | .Vb 1 | |
281 | \& # Put Perl code used in the BOOT: section here | |
282 | .Ve | |
283 | .PP | |
284 | .Vb 2 | |
285 | \& XSLoader::load 'YourPackage', $VERSION; | |
286 | \& } | |
287 | .Ve | |
288 | .PP | |
289 | .Vb 1 | |
290 | \& # Put Perl code making calls into XSUBs here | |
291 | .Ve | |
292 | .Sh "The most hairy case" | |
293 | .IX Subsection "The most hairy case" | |
294 | If the interdependence of your \f(CW\*(C`BOOT:\*(C'\fR section and Perl code is | |
295 | more complicated than this (e.g., the \f(CW\*(C`BOOT:\*(C'\fR section makes calls to Perl | |
296 | functions which make calls to XSUBs with prototypes), get rid of the \f(CW\*(C`BOOT:\*(C'\fR | |
297 | section altogether. Replace it with a function \f(CW\*(C`onBOOT()\*(C'\fR, and call it like | |
298 | this: | |
299 | .PP | |
300 | .Vb 3 | |
301 | \& package YourPackage; | |
302 | \& use XSLoader; | |
303 | \& use vars qw($VERSION @ISA); | |
304 | .Ve | |
305 | .PP | |
306 | .Vb 5 | |
307 | \& BEGIN { | |
308 | \& @ISA = qw( OnePackage OtherPackage ); | |
309 | \& $VERSION = '0.01'; | |
310 | \& XSLoader::load 'YourPackage', $VERSION; | |
311 | \& } | |
312 | .Ve | |
313 | .PP | |
314 | .Vb 2 | |
315 | \& # Put Perl code used in onBOOT() function here; calls to XSUBs are | |
316 | \& # prototype-checked. | |
317 | .Ve | |
318 | .PP | |
319 | .Vb 1 | |
320 | \& onBOOT; | |
321 | .Ve | |
322 | .PP | |
323 | .Vb 1 | |
324 | \& # Put Perl initialization code assuming that XS is initialized here | |
325 | .Ve | |
326 | .SH "DIAGNOSTICS" | |
327 | .IX Header "DIAGNOSTICS" | |
328 | .ie n .IP "Can't find '%s' symbol in %s" 4 | |
329 | .el .IP "Can't find '%s' symbol in \f(CW%s\fR" 4 | |
330 | .IX Item "Can't find '%s' symbol in %s" | |
331 | \&\fB(F)\fR The bootstrap symbol could not be found in the extension module. | |
332 | .ie n .IP "Can't load '%s' for module %s:\fR \f(CW%s" 4 | |
333 | .el .IP "Can't load '%s' for module \f(CW%s:\fR \f(CW%s\fR" 4 | |
334 | .IX Item "Can't load '%s' for module %s: %s" | |
335 | \&\fB(F)\fR The loading or initialisation of the extension module failed. | |
336 | The detailed error follows. | |
337 | .ie n .IP "Undefined symbols present after loading %s:\fR \f(CW%s" 4 | |
338 | .el .IP "Undefined symbols present after loading \f(CW%s:\fR \f(CW%s\fR" 4 | |
339 | .IX Item "Undefined symbols present after loading %s: %s" | |
340 | \&\fB(W)\fR As the message says, some symbols stay undefined although the | |
341 | extension module was correctly loaded and initialised. The list of undefined | |
342 | symbols follows. | |
343 | .ie n .IP "XSLoader::load('Your::Module', $Your::Module::VERSION)" 4 | |
344 | .el .IP "XSLoader::load('Your::Module', \f(CW$Your::Module::VERSION\fR)" 4 | |
345 | .IX Item "XSLoader::load('Your::Module', $Your::Module::VERSION)" | |
346 | \&\fB(F)\fR You tried to invoke \f(CW\*(C`load()\*(C'\fR without any argument. You must supply | |
347 | a module name, and optionally its version. | |
348 | .SH "LIMITATIONS" | |
349 | .IX Header "LIMITATIONS" | |
350 | To reduce the overhead as much as possible, only one possible location | |
351 | is checked to find the extension \s-1DLL\s0 (this location is where \f(CW\*(C`make install\*(C'\fR | |
352 | would put the \s-1DLL\s0). If not found, the search for the \s-1DLL\s0 is transparently | |
353 | delegated to \f(CW\*(C`DynaLoader\*(C'\fR, which looks for the \s-1DLL\s0 along the \f(CW@INC\fR list. | |
354 | .PP | |
355 | In particular, this is applicable to the structure of \f(CW@INC\fR used for testing | |
356 | not-yet-installed extensions. This means that running uninstalled extensions | |
357 | may have much more overhead than running the same extensions after | |
358 | \&\f(CW\*(C`make install\*(C'\fR. | |
359 | .SH "BUGS" | |
360 | .IX Header "BUGS" | |
361 | Please report any bugs or feature requests via the \fIperlbug\fR\|(1) utility. | |
362 | .SH "SEE ALSO" | |
363 | .IX Header "SEE ALSO" | |
364 | DynaLoader | |
365 | .SH "AUTHORS" | |
366 | .IX Header "AUTHORS" | |
367 | Ilya Zakharevich originally extracted \f(CW\*(C`XSLoader\*(C'\fR from \f(CW\*(C`DynaLoader\*(C'\fR. | |
368 | .PP | |
369 | \&\s-1CPAN\s0 version is currently maintained by Se\*'bastien Aperghis-Tramoni | |
370 | <sebastien@aperghis.net> | |
371 | .PP | |
372 | Previous maintainer was Michael G Schwern <schwern@pobox.com> | |
373 | .SH "COPYRIGHT" | |
374 | .IX Header "COPYRIGHT" | |
375 | This program is free software; you can redistribute it and/or modify | |
376 | it under the same terms as Perl itself. |