📄 ch08_70.htm
字号:
<html><head><title>ExtUtils::Embed (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 & 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_69.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_71.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr></table></div><h2 class="sect1">8.70. ExtUtils::Embed</h2><p><a name="INDEX-1415" />Generally called from the Makefile thatbuilds your application to provide initialization functions forembedding Perl code in C or C++ applications. For example:</p><blockquote><pre class="code">perl -MExtUtils::Embed -e xsinit perl -MExtUtils::Embed -e ldopts</pre></blockquote><p>Uses the configuration information kept in<em class="emphasis">Config.pm</em> (see the Config module above). Exportsthe following functions.</p><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>ccdlflags</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>ccdlflags</pre><p>Prints <tt class="literal">$Config{ccdlflags}</tt>.</p></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>ccflags</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>ccflags</pre><p>Prints <tt class="literal">$Config{ccflags}</tt>.</p></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>ccopts</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>ccopts</pre><p>Combines <tt class="literal">perl_inc</tt>, <tt class="literal">ccflags</tt>, and<tt class="literal">ccdlflags</tt>.</p></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>ldopts</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>ldopts</pre><p>Outputs arguments for linking the Perl library and extensions to yourapplication. When invoked as:</p><blockquote><pre class="code">perl -MExtUtils::Embed -e ldopts -</pre></blockquote><p>the following options are recognized:</p><dl><dt><i><em class="emphasis">-std</em></i></dt><dd>Outputs arguments for linking the Perl library and any extensionslinked with the current Perl.</p></dd><dt><i><em class="emphasis">-I <path1:path2></em></i></dt><dd>Search path for <em class="emphasis">ModuleName.a</em> archives. Defaultis <tt class="literal">@INC</tt>.</p></dd><dt><i> <em class="emphasis">-- <list of linker args></em></i></dt><dd>Additional linker arguments to be considered.</p></dd></dl><p>Any additional arguments found before the -- token are taken asthe names of modules to generate code for. Can also be called withparameters:</p><blockquote><pre class="code">'ldopts($std,[@modules],[@link_args],$path)'</pre></blockquote><p>When called this way, returns the argument string rather thanprinting it to STDOUT. The optional parameters are:</p><dl><dt><b><tt class="literal">$</tt><em class="replaceable">std</em></b></dt><dd>Boolean, equivalent to the <em class="emphasis">-std</em> option.</p></dd><dt><b><tt class="literal">[@</tt><em class="replaceable">modules</em><tt class="literal">]</tt></b></dt><dd>Array reference. Equivalent to adding module names before the -- token.</p></dd><dt><b><tt class="literal">[@</tt><em class="replaceable">link_args</em><tt class="literal">]</tt></b></dt><dd>Array reference. Equivalent to adding linker arguments after the -- token.</p></dd><dt><b><tt class="literal">$</tt><em class="replaceable">path</em></b></dt><dd>Equivalent to the <em class="emphasis">-I</em> option.</p></dd></dl></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>perl_inc</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>perl_inc</pre><p>For including Perl header files. For example, if you say: </p><blockquote><pre class="code">perl -MExtUtils::Embed -eperl_inc</pre></blockquote><p>the module prints the following: </p><blockquote><pre class="code">-I$Config{archlibexp}/CORE</pre></blockquote></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>xsi_body</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>xsi_body (<em class="replaceable">modules</em>)</pre><p>Returns string of calls to <tt class="literal">newXS</tt> that glue themodule bootstrap function to <tt class="literal">boot_ModuleName</tt> foreach module in <em class="replaceable"><tt>modules</tt></em>.</p></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>xsi_header</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>xsi_header</pre><p>Returns a string defining the same EXTERN_C macro as<em class="emphasis">perlmain.c</em>; also <tt class="literal">#include</tt> s<em class="emphasis">perl.h</em> and <em class="emphasis">EXTERN.h</em>.</p></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>xsinit</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>xsinit</pre><p>Generates C/C++ code for the XS initializer function. When invokedas:</p><blockquote><pre class="code">perl -MExtUtils::Embed -e xsinit -</pre></blockquote><p>the following options are recognized:</p><dl><dt><i><em class="emphasis">-o</em> <tt class="literal">[</tt><em class="replaceable"><tt>filename</tt></em><tt class="literal">]</tt></i></dt><dd>Prints to the filename specified. Defaults to<em class="emphasis">perlxsi.c</em>. If<em class="replaceable"><tt>filename</tt></em> is STDOUT, prints to standardoutput.</p></dd><dt><i><em class="emphasis">-std</em></i></dt><dd>Writes code for extensions that are linked with the current Perl.</p><p>Any additional arguments are expected to be names of modules togenerate code for. Can also be called with parameters:</p><blockquote><pre class="code">'xsinit($filename,$std,[@modules])'</pre></blockquote><p>When called this way, the following optional parameters are accepted:</p><dl><dt><b><tt class="literal">$</tt><em class="replaceable">filename</em></b></dt><dd>Equivalent to the <em class="emphasis">-o</em> option.</p></dd><dt><b><tt class="literal">$std</tt></b></dt><dd>Boolean. Equivalent to the <em class="emphasis">-std</em> option.</p></dd><dt><b><tt class="literal">[@</tt><em class="replaceable">modules</em><tt class="literal">]</tt></b></dt><dd>An array reference. Equivalent to adding module names after the<tt class="literal">--</tt> token.</p></dd></dl></dd></dl></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>xsi_protos</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>xsi_protos (<em class="replaceable">modules</em>)</pre><p>Returns string of <tt class="literal">boot_$ModuleName</tt> prototypes foreach module in <em class="replaceable"><tt>modules</tt></em>.</p></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_69.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_71.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr><tr><td align="left" valign="top" width="228">8.69. ExtUtils::Constant</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.71. ExtUtils::Install</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 © 2002</a> O'Reilly & 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 + -