PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms


HTML | 100 lines | 76 code | 24 blank | 0 comment | 0 complexity | 0660102b02ddc6afa43fcb920a880925 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. <tt>$Header$</tt><br>
  8. <p>
  9. The following examples illustrate the use of SWIG with Perl.
  10. <ul>
  11. <li><a href="simple/index.html">simple</a>. A minimal example showing how SWIG can
  12. be used to wrap a C function and a global variable.
  13. <li><a href="constants/index.html">constants</a>. This shows how preprocessor macros and
  14. certain C declarations are turned into constants.
  15. <li><a href="variables/index.html">variables</a>. This example shows how to access C global variables from Perl.
  16. <li><a href="value/index.html">value</a>. How to pass and return structures by value.
  17. <li><a href="class/index.html">class</a>. How to wrap a simple C++ class.
  18. <li><a href="reference/index.html">reference</a>. C++ references.
  19. <li><a href="pointer/index.html">pointer</a>. Simple pointer handling.
  20. <li><a href="funcptr/index.html">funcptr</a>. Pointers to functions.
  21. </ul>
  22. <h2>Compilation Issues</h2>
  23. <ul>
  24. <li>To create a Perl extension, SWIG is run with the following options:
  25. <blockquote>
  26. <pre>
  27. % swig -perl5 interface.i
  28. </pre>
  29. </blockquote>
  30. <li>The compilation of examples is done using the file <tt>Example/Makefile</tt>. This
  31. makefile performs a manual module compilation which is platform specific. Typically,
  32. the steps look like this (Linux):
  33. <blockquote>
  34. <pre>
  35. % swig -perl5 interface.i
  36. % gcc -fpic -c -Dbool=char -I/usr/lib/perl5/5.00503/i386-linux/CORE interface_wrap.c
  37. % gcc -shared interface_wrap.o $(OBJS) -o
  38. % perl
  39. use interface;
  40. ...
  41. </pre>
  42. </blockquote>
  43. <li>The politically "correct" way to compile a Perl extension module is to use MakeMaker
  44. and related tools (especially if you are considering third-party distribution). Consult
  45. a book such as Advanced Perl Programming for details.
  46. </ul>
  47. <h2>Compatibility</h2>
  48. The examples have been extensively tested on the following platforms:
  49. <p>
  50. <ul>
  51. <li>Linux
  52. <li>Solaris
  53. </ul>
  54. 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>
  55. The most recent version of Perl used for testing is as follows:
  56. <blockquote>
  57. <pre>
  58. % perl -version
  59. This is perl, v5.6.0 built for sun4-solaris
  60. Copyright 1987-2000, Larry Wall
  61. Perl may be copied only under the terms of either the Artistic License or the
  62. GNU General Public License, which may be found in the Perl 5.0 source kit.
  63. Complete documentation for Perl, including FAQ lists, should be found on
  64. this system using `man perl' or `perldoc perl'. If you have access to the
  65. Internet, point your browser at, the Perl Home Page.
  66. </pre>
  67. </blockquote>
  68. <p>
  69. Due to wide variations in the Perl C API and differences between versions such as the ActivePerl release for Windows,
  70. the code generated by SWIG is extremely messy. We have made every attempt to maintain compatibility with
  71. many Perl releases going as far back as 5.003 and as recent as 5.6. However, your mileage may vary.
  72. If you experience a problem, please let us know by
  73. contacting us on the <a href="">mailing lists</a>.
  74. Better yet, send us a patch.
  75. </body>
  76. </html>