home *** CD-ROM | disk | FTP | other *** search
-
- <HTML>
- <HEAD>
- <TITLE>ExtUtils::Embed - Utilities for embedding Perl in C/C++ applications</TITLE>
- <LINK REL="stylesheet" HREF="../../Active.css" TYPE="text/css">
- <LINK REV="made" HREF="mailto:">
- </HEAD>
-
- <BODY>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> ExtUtils::Embed - Utilities for embedding Perl in C/C++ applications</P></STRONG>
- </TD></TR>
- </TABLE>
-
- <A NAME="__index__"></A>
- <!-- INDEX BEGIN -->
-
- <UL>
-
- <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
-
- <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
- <LI><A HREF="#description">DESCRIPTION</A></LI>
- <LI><A HREF="#@export">@EXPORT</A></LI>
- <LI><A HREF="#functions">FUNCTIONS</A></LI>
- <LI><A HREF="#examples">EXAMPLES</A></LI>
- <LI><A HREF="#see also">SEE ALSO</A></LI>
- <LI><A HREF="#author">AUTHOR</A></LI>
- </UL>
- <!-- INDEX END -->
-
- <HR>
- <P>
- <H1><A NAME="name">NAME</A></H1>
- <P>ExtUtils::Embed - Utilities for embedding Perl in C/C++ applications</P>
- <P>
- <HR>
- <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
- <UL>
- <LI>Linux</LI>
- <LI>Solaris</LI>
- <LI>Windows</LI>
- </UL>
- <HR>
- <H1><A NAME="synopsis">SYNOPSIS</A></H1>
- <PRE>
- perl -MExtUtils::Embed -e xsinit
- perl -MExtUtils::Embed -e ldopts</PRE>
- <P>
- <HR>
- <H1><A NAME="description">DESCRIPTION</A></H1>
- <P>ExtUtils::Embed provides utility functions for embedding a Perl interpreter
- and extensions in your C/C++ applications.
- Typically, an application <STRONG>Makefile</STRONG> will invoke ExtUtils::Embed
- functions while building your application.</P>
- <P>
- <HR>
- <H1><A NAME="@export">@EXPORT</A></H1>
- <P>ExtUtils::Embed exports the following functions:</P>
- <P>xsinit(), ldopts(), ccopts(), perl_inc(), ccflags(),
- ccdlflags(), xsi_header(), xsi_protos(), <A HREF="#item_xsi_body"><CODE>xsi_body()</CODE></A></P>
- <P>
- <HR>
- <H1><A NAME="functions">FUNCTIONS</A></H1>
- <DL>
- <DT><STRONG><A NAME="item_xsinit"><CODE>xsinit()</CODE></A></STRONG><BR>
- <DD>
- Generate C/C++ code for the XS initializer function.
- <P>When invoked as <CODE>`perl -MExtUtils::Embed -e xsinit --`</CODE>
- the following options are recognized:</P>
- <P><STRONG>-o</STRONG> <output filename> (Defaults to <STRONG>perlxsi.c</STRONG>)</P>
- <P><STRONG>-o STDOUT</STRONG> will print to STDOUT.</P>
- <P><STRONG>-std</STRONG> (Write code for extensions that are linked with the current Perl.)</P>
- <P>Any additional arguments are expected to be names of modules
- to generate code for.</P>
- <P>When invoked with parameters the following are accepted and optional:</P>
- <P><A HREF="#item_xsinit"><CODE>xsinit($filename,$std,[@modules])</CODE></A></P>
- <P>Where,</P>
- <P><STRONG>$filename</STRONG> is equivalent to the <STRONG>-o</STRONG> option.</P>
- <P><STRONG>$std</STRONG> is boolean, equivalent to the <STRONG>-std</STRONG> option.</P>
- <P><STRONG>[@modules]</STRONG> is an array ref, same as additional arguments mentioned above.</P>
- <P></P>
- <DT><STRONG><A NAME="item_Examples">Examples</A></STRONG><BR>
- <DD>
- <PRE>
- perl -MExtUtils::Embed -e xsinit -- -o xsinit.c Socket</PRE>
- <P>This will generate code with an <STRONG>xs_init</STRONG> function that glues the perl <STRONG>Socket::bootstrap</STRONG> function
- to the C <STRONG>boot_Socket</STRONG> function and writes it to a file named <EM>xsinit.c</EM>.</P>
- <P>Note that <STRONG>DynaLoader</STRONG> is a special case where it must call <STRONG>boot_DynaLoader</STRONG> directly.</P>
- <PRE>
- perl -MExtUtils::Embed -e xsinit</PRE>
- <P>This will generate code for linking with <STRONG>DynaLoader</STRONG> and
- each static extension found in <STRONG>$Config{static_ext}</STRONG>.
- The code is written to the default file name <STRONG>perlxsi.c</STRONG>.</P>
- <PRE>
- perl -MExtUtils::Embed -e xsinit -- -o xsinit.c -std DBI DBD::Oracle</PRE>
- <P>Here, code is written for all the currently linked extensions along with code
- for <STRONG>DBI</STRONG> and <STRONG>DBD::Oracle</STRONG>.</P>
- <P>If you have a working <STRONG>DynaLoader</STRONG> then there is rarely any need to statically link in any
- other extensions.</P>
- <DT><STRONG><A NAME="item_ldopts"><CODE>ldopts()</CODE></A></STRONG><BR>
- <DD>
- Output arguments for linking the Perl library and extensions to your
- application.
- <P>When invoked as <CODE>`perl -MExtUtils::Embed -e ldopts --`</CODE>
- the following options are recognized:</P>
- <P><STRONG>-std</STRONG></P>
- <P>Output arguments for linking the Perl library and any extensions linked
- with the current Perl.</P>
- <P><STRONG>-I</STRONG> <path1:path2></P>
- <P>Search path for ModuleName.a archives.
- Default path is <STRONG>@INC</STRONG>.
- Library archives are expected to be found as
- <STRONG>/some/path/auto/ModuleName/ModuleName.a</STRONG>
- For example, when looking for <STRONG>Socket.a</STRONG> relative to a search path,
- we should find <STRONG>auto/Socket/Socket.a</STRONG></P>
- <P>When looking for <STRONG>DBD::Oracle</STRONG> relative to a search path,
- we should find <STRONG>auto/DBD/Oracle/Oracle.a</STRONG></P>
- <P>Keep in mind that you can always supply <STRONG>/my/own/path/ModuleName.a</STRONG>
- as an additional linker argument.</P>
- <P><STRONG>--</STRONG> <list of linker args></P>
- <P>Additional linker arguments to be considered.</P>
- <P>Any additional arguments found before the <STRONG>--</STRONG> token
- are expected to be names of modules to generate code for.</P>
- <P>When invoked with parameters the following are accepted and optional:</P>
- <P><A HREF="#item_ldopts"><CODE>ldopts($std,[@modules],[@link_args],$path)</CODE></A></P>
- <P>Where:</P>
- <P><STRONG>$std</STRONG> is boolean, equivalent to the <STRONG>-std</STRONG> option.</P>
- <P><STRONG>[@modules]</STRONG> is equivalent to additional arguments found before the <STRONG>--</STRONG> token.</P>
- <P><STRONG>[@link_args]</STRONG> is equivalent to arguments found after the <STRONG>--</STRONG> token.</P>
- <P><STRONG>$path</STRONG> is equivalent to the <STRONG>-I</STRONG> option.</P>
- <P>In addition, when ldopts is called with parameters, it will return the argument string
- rather than print it to STDOUT.</P>
- <P></P>
- <DT><STRONG>Examples</STRONG><BR>
- <DD>
- <PRE>
- perl -MExtUtils::Embed -e ldopts</PRE>
- <P>This will print arguments for linking with <STRONG>libperl.a</STRONG>, <STRONG>DynaLoader</STRONG> and
- extensions found in <STRONG>$Config{static_ext}</STRONG>. This includes libraries
- found in <STRONG>$Config{libs}</STRONG> and the first ModuleName.a library
- for each extension that is found by searching <STRONG>@INC</STRONG> or the path
- specified by the <STRONG>-I</STRONG> option.
- In addition, when ModuleName.a is found, additional linker arguments
- are picked up from the <STRONG>extralibs.ld</STRONG> file in the same directory.</P>
- <PRE>
- perl -MExtUtils::Embed -e ldopts -- -std Socket</PRE>
- <P>This will do the same as the above example, along with printing additional arguments for linking with the <STRONG>Socket</STRONG> extension.</P>
- <PRE>
- perl -MExtUtils::Embed -e ldopts -- DynaLoader</PRE>
- <P>This will print arguments for linking with just the <STRONG>DynaLoader</STRONG> extension
- and <STRONG>libperl.a</STRONG>.</P>
- <PRE>
- perl -MExtUtils::Embed -e ldopts -- -std Msql -- -L/usr/msql/lib -lmsql</PRE>
- <P>Any arguments after the second '--' token are additional linker
- arguments that will be examined for potential conflict. If there is no
- conflict, the additional arguments will be part of the output.</P>
- <DT><STRONG><A NAME="item_perl_inc"><CODE>perl_inc()</CODE></A></STRONG><BR>
- <DD>
- For including perl header files this function simply prints:
- <PRE>
- -I$Config{archlibexp}/CORE</PRE>
- <P>So, rather than having to say:</P>
- <PRE>
- perl -MConfig -e 'print "-I$Config{archlibexp}/CORE"'</PRE>
- <P>Just say:</P>
- <PRE>
- perl -MExtUtils::Embed -e perl_inc</PRE>
- <P></P>
- <DT><STRONG><A NAME="item_ccflags">ccflags(), <CODE>ccdlflags()</CODE></A></STRONG><BR>
- <DD>
- These functions simply print $Config{ccflags} and $Config{ccdlflags}
- <P></P>
- <DT><STRONG><A NAME="item_ccopts"><CODE>ccopts()</CODE></A></STRONG><BR>
- <DD>
- This function combines perl_inc(), <A HREF="#item_ccflags"><CODE>ccflags()</CODE></A> and <CODE>ccdlflags()</CODE> into one.
- <P></P>
- <DT><STRONG><A NAME="item_xsi_header"><CODE>xsi_header()</CODE></A></STRONG><BR>
- <DD>
- This function simply returns a string defining the same <STRONG>EXTERN_C</STRONG> macro as
- <STRONG>perlmain.c</STRONG> along with #including <STRONG>perl.h</STRONG> and <STRONG>EXTERN.h</STRONG>.
- <P></P>
- <DT><STRONG><A NAME="item_xsi_protos"><CODE>xsi_protos(@modules)</CODE></A></STRONG><BR>
- <DD>
- This function returns a string of <STRONG>boot_$ModuleName</STRONG> prototypes for each @modules.
- <P></P>
- <DT><STRONG><A NAME="item_xsi_body"><CODE>xsi_body(@modules)</CODE></A></STRONG><BR>
- <DD>
- This function returns a string of calls to <STRONG>newXS()</STRONG> that glue the module <STRONG>bootstrap</STRONG>
- function to <STRONG>boot_ModuleName</STRONG> for each @modules.
- <P><STRONG>xsinit()</STRONG> uses the xsi_* functions to generate most of it's code.</P>
- <P></P></DL>
- <P>
- <HR>
- <H1><A NAME="examples">EXAMPLES</A></H1>
- <P>For examples on how to use <STRONG>ExtUtils::Embed</STRONG> for building C/C++ applications
- with embedded perl, see the eg/ directory and <A HREF="../../lib/Pod/perlembed.html">the perlembed manpage</A>.</P>
- <P>
- <HR>
- <H1><A NAME="see also">SEE ALSO</A></H1>
- <P><A HREF="../../lib/Pod/perlembed.html">the perlembed manpage</A></P>
- <P>
- <HR>
- <H1><A NAME="author">AUTHOR</A></H1>
- <P>Doug MacEachern <<EM><A HREF="mailto:dougm@osf.org">dougm@osf.org</A></EM>></P>
- <P>Based on ideas from Tim Bunce <<EM><A HREF="mailto:Tim.Bunce@ig.co.uk">Tim.Bunce@ig.co.uk</A></EM>> and
- <STRONG>minimod.pl</STRONG> by Andreas Koenig <<EM><A HREF="mailto:k@anna.in-berlin.de">k@anna.in-berlin.de</A></EM>> and Tim Bunce.</P>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> ExtUtils::Embed - Utilities for embedding Perl in C/C++ applications</P></STRONG>
- </TD></TR>
- </TABLE>
-
- </BODY>
-
- </HTML>
-