⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch08_61.htm

📁 by Randal L. Schwartz and Tom Phoenix ISBN 0-596-00132-0 Third Edition, published July 2001. (See
💻 HTM
字号:
<html><head><title>DynaLoader (Perl in a Nutshell, 2nd Edition)</title><link rel="stylesheet" type="text/css" href="../style/style1.css" /><meta name="DC.Creator" content="Stephen Spainhour" /><meta name="DC.Format" content="text/xml" scheme="MIME" /><meta name="DC.Language" content="en-US" /><meta name="DC.Publisher" content="O'Reilly &amp; Associates, Inc." /><meta name="DC.Source" scheme="ISBN" content="0596002416L" /><meta name="DC.Subject.Keyword" content="stuff" /><meta name="DC.Title" content="Perl in a Nutshell, 2nd Edition" /><meta name="DC.Type" content="Text.Monograph" /></head><body bgcolor="#ffffff"><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home" /><map name="banner-map"><area shape="rect" coords="1,-2,616,66" href="index.htm" alt="Java and XSLT" /><area shape="rect" coords="629,-11,726,25" href="jobjects/fsearch.htm" alt="Search this book" /></map><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch08_60.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228" /><td align="right" valign="top" width="228"><a href="ch08_62.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr></table></div><h2 class="sect1">8.61. DynaLoader</h2><p><a name="INDEX-1391" /><a name="INDEX-1392" /><a name="INDEX-1393" />The standard Perl interface to thedynamic linking mechanisms available on many platforms.</p><a name="perlnut2-CHP-8-SECT-61.1" /><div class="sect2"><h3 class="sect2">8.61.1. Using DynaLoader</h3><p>Use DynaLoader like this: </p><blockquote><pre class="code">package <em class="replaceable"><tt>Module</tt></em>;require DynaLoader;@ISA = qw(... DynaLoader ...);bootstrap <em class="replaceable"><tt>Module</tt></em>;</pre></blockquote><p>The <tt class="literal">bootstrap</tt> method calls yourmodule's bootstrap routine directly if the module isstatically linked into Perl. Otherwise, the module inherits the<tt class="literal">bootstrap</tt> method from DynaLoader, which loads inyour module and calls its <tt class="literal">bootstrap</tt> method.</p></div><a name="perlnut2-CHP-8-SECT-61.2" /><div class="sect2"><h3 class="sect2">8.61.2. Extending to New Architectures</h3><p>If you want to extend DynaLoader to a new architecture, you need toknow about its internal interface. The variables it uses are:</p><dl><dt><b><tt class="literal">$dl_debug</tt></b></dt><dd>Enables internal debugging messages on the Perl side of theDynaLoader; by default, is set to<tt class="literal">$ENV{'PERL_DL_DEBUG'}</tt> if that is defined. Asimilar debugging variable is added to the C code (see<em class="emphasis">dlutils.c</em>) and enabled if Perl was built withthe <em class="emphasis">-DDEBUGGING</em> flag, or it can be set via thePERL_DL_DEBUG environment variable. Set to <tt class="literal">1</tt> forminimal information or higher for more detail.</p></dd><dt><b><tt class="literal">@dl_library_path</tt></b></dt><dd>Default list of directories to search for libraries; initialized tohold the list of directories in <tt class="literal">$Config{'libpth'}</tt>.Should also be initialized with other directories that can bedetermined from the environment at runtime.</p></dd><dt><b><tt class="literal">@dl_resolve_using</tt></b></dt><dd>List of additional libraries or other shared objects for resolvingundefined symbols. Required only on platforms without automatichandling for dependent libraries.</p></dd><dt><b><tt class="literal">@dl_require_symbols</tt></b></dt><dd>List of one or more symbol names in the library/object file to bedynamically loaded. Only required on some platforms.</p></dd></dl><p>Of the following subroutines, <tt class="literal">bootstrap</tt> and<tt class="literal">dl_findfile</tt> are standard across all platforms andare defined in <em class="emphasis">DynaLoader.pm</em>. The others aredefined in the <em class="emphasis">.xs</em> file that supplies theimplementation for the platform.</p><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>bootstrap</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>bootstrap (<em class="replaceable">modulename</em>)</pre><p>Normal entry point for automatic dynamic loading in Perl.</p></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>dl_error</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>dl_error</pre><p>Gets error message text from the last failed DynaLoader function: </p><blockquote><pre class="code">$message = dl_error(  );</pre></blockquote></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>dl_expandspec</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>dl_expandspec (<em class="replaceable">spec</em>)</pre><p>Used for systems that require special filename handling to deal withsymbolic names for files. <em class="replaceable"><tt>spec</tt></em> specifiesthe filenames that need the special handling.</p></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>dl_findfile</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>dl_findfile (<em class="replaceable">names</em>)</pre><p>Determines the full paths to one or more loadable files, given theirgeneric names and optionally one or more directories. Searchesdirectories in <tt class="literal">@dl_library_path</tt> by default andreturns an empty list if no files are found.</p></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>dl_find_symbol</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>dl_find_symbol (<em class="replaceable">libref</em>, <em class="replaceable">symbol</em>)</pre><p>Looks in <em class="replaceable">libref</em> for the address of symbol<em class="replaceable"><tt>symbol</tt></em>. Returns the address, or<tt class="literal">undef</tt> if not found.</p></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>dl_install_xsub</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>dl_install_xsub (<em class="replaceable">perl_name</em>, <em class="replaceable">symref</em>[, <em class="replaceable">filename</em>])</pre><p>Creates a new Perl external subroutine. Takes the following arguments:</p><dl><dt><i><em class="replaceable"><tt>perl_name</tt></em></i></dt><dd>Name of the new subroutine.</p></dd><dt><i><em class="replaceable"><tt>symref</tt></em></i></dt><dd>Pointer to the function that implements the routine.</p></dd><dt><i><em class="replaceable"><tt>filename</tt></em></i></dt><dd>The source file for the function. If not defined, DynaLoader is used.</p></dd></dl></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>dl_load_file</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>dl_load_file (<em class="replaceable">filename</em>)</pre><p>Dynamically loads <em class="replaceable">filename</em>, which must bethe path to a shared object or library; returns<tt class="literal">undef</tt> on error.</p></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>dl_undef_symbols</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>dl_undef_symbols</pre><p>Returns list of symbol names that remain undefined after<tt class="literal">dl_load_file</tt>, or <tt class="literal">( )</tt> if thenames are unknown.</p></div></div><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch08_60.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0" /></a></td><td align="right" valign="top" width="228"><a href="ch08_62.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr><tr><td align="left" valign="top" width="228">8.60. Dumpvalue</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0" /></a></td><td align="right" valign="top" width="228">8.62. encoding</td></tr></table></div><hr width="684" align="left" /><img src="../gifs/navbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links" /><p><p><font size="-1"><a href="copyrght.htm">Copyright &copy; 2002</a> O'Reilly &amp; Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,85,94" href="../index.htm"><area shape="rect" coords="86,1,178,103" href="../lwp/index.htm"><area shape="rect" coords="180,0,265,103" href="../lperl/index.htm"><area shape="rect" coords="267,0,353,105" href="../perlnut/index.htm"><area shape="rect" coords="354,1,446,115" href="../prog/index.htm"><area shape="rect" coords="448,0,526,132" href="../tk/index.htm"><area shape="rect" coords="528,1,615,119" href="../cookbook/index.htm"><area shape="rect" coords="617,0,690,135" href="../pxml/index.htm"></map></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -