PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/perl5/index.html

#
HTML | 79 lines | 61 code | 18 blank | 0 comment | 0 complexity | 7053aa3035ca38593b99ee5cf800c194 MD5 | raw file
 1<html>
 2<head>
 3<title>SWIG:Examples:perl5</title>
 4</head>
 5
 6<body bgcolor="#ffffff">
 7<H1>SWIG Perl Examples</H1>
 8
 9<p>
10The following examples illustrate the use of SWIG with Perl.
11
12<ul>
13<li><a href="simple/index.html">simple</a>.  A minimal example showing how SWIG can
14be used to wrap a C function and a global variable.
15<li><a href="constants/index.html">constants</a>.  This shows how preprocessor macros and
16certain C declarations are turned into constants.
17<li><a href="variables/index.html">variables</a>.  This example shows how to access C global variables from Perl.
18<li><a href="value/index.html">value</a>. How to pass and return structures by value.
19<li><a href="class/index.html">class</a>. How to wrap a simple C++ class.
20<li><a href="reference/index.html">reference</a>. C++ references.
21<li><a href="pointer/index.html">pointer</a>. Simple pointer handling.
22<li><a href="funcptr/index.html">funcptr</a>. Pointers to functions.
23</ul>
24
25<h2>Compilation Issues</h2>
26
27<ul>
28<li>To create a Perl extension, SWIG is run with the following options:
29
30<blockquote>
31<pre>
32% swig -perl5 interface.i
33</pre>
34</blockquote>
35
36<li>The compilation of examples is done using the file <tt>Example/Makefile</tt>.  This
37makefile performs a manual module compilation which is platform specific.  Typically,
38the steps look like this (Linux):
39
40<blockquote>
41<pre>
42% swig -perl5 interface.i
43% gcc -fpic -c -Dbool=char -I/usr/lib/perl5/5.00503/i386-linux/CORE interface_wrap.c
44% gcc -shared interface_wrap.o $(OBJS) -o interface.so 
45% perl
46use interface;
47...
48</pre>
49</blockquote>
50
51<li>The politically "correct" way to compile a Perl extension module is to use MakeMaker
52and related tools (especially if you are considering third-party distribution).  Consult
53a book such as Advanced Perl Programming for details.
54
55</ul>
56
57<h2>Compatibility</h2>
58
59The examples have been extensively tested on the following platforms:
60
61<p>
62<ul>
63<li>Linux
64<li>Solaris
65</ul>
66
67Please see the <a href="../../Doc/Manual/Windows.html">Windows</a> page in the main manual for information on using the examples on Windows. <p>
68
69<p>
70Due to wide variations in the Perl C API and differences between versions such as the ActivePerl release for Windows,
71the code generated by SWIG is extremely messy.
72If the code doesn't compile or work with your version of Perl, please let us know by 
73contacting us on the <a href="http://www.swig.org/mail.html">mailing lists</a>.
74Better yet, send us a patch.
75
76</body>
77</html>
78
79