PageRenderTime 52ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/perl5/index.html

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