PageRenderTime 34ms CodeModel.GetById 8ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1.3.35/Examples/ruby/index.html

#
HTML | 94 lines | 74 code | 20 blank | 0 comment | 0 complexity | 1be53227317a2386bde41187fa4b0c59 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. <head>
  2. <title>SWIG:Examples:ruby</title>
  3. </head>
  4. <body bgcolor="#ffffff">
  5. <H1>SWIG Ruby Examples</H1>
  6. <p>
  7. The following examples illustrate the use of SWIG with Ruby.
  8. <ul>
  9. <li><a href="simple/index.html">simple</a>. A minimal example showing how SWIG can
  10. be used to wrap a C function, a global variable, and a constant.
  11. <li><a href="constants/index.html">constants</a>. This shows how preprocessor macros and
  12. certain C declarations are turned into constants.
  13. <li><a href="variables/index.html">variables</a>. An example showing how to access C global variables from Ruby.
  14. <li><a href="value/index.html">value</a>. How to pass and return structures by value.
  15. <li><a href="class/index.html">class</a>. Wrapping a simple C++ class.
  16. <li><a href="reference/index.html">reference</a>. C++ references.
  17. <li><a href="pointer/index.html">pointer</a>. Simple pointer handling.
  18. <li><a href="funcptr/index.html">funcptr</a>. Pointers to functions.
  19. <li><a href="enum/index.html">enum</a>. Enumeration.
  20. </ul>
  21. <h2>Compilation Issues</h2>
  22. <ul>
  23. <li>To create a Ruby extension, SWIG is run with the following options:
  24. <blockquote>
  25. <pre>
  26. % swig -ruby interface.i
  27. </pre>
  28. </blockquote>
  29. <li>
  30. 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>
  31. </li>
  32. <li>On Unix the compilation of examples is done using the file <tt>Example/Makefile</tt>. This
  33. makefile performs a manual module compilation which is platform specific. Typically,
  34. the steps look like this (Linux):
  35. <blockquote>
  36. <pre>
  37. % swig -ruby interface.i
  38. % gcc -fpic -c interface_wrap.c -I/usr/local/lib/ruby/1.4/i686-linux
  39. % gcc -shared interface_wrap.o $(OBJS) -o interface.so
  40. % ruby
  41. require 'interface'
  42. Interface.blah(...)
  43. ...
  44. </pre>
  45. </blockquote>
  46. <li>The politically "correct" way to compile a Ruby extension is to follow the steps
  47. described <tt>README.EXT</tt> in Ruby distribution:
  48. <p>
  49. <ol>
  50. <li>Create a file called <tt>extconf.rb</tt> that looks like the following:
  51. <blockquote>
  52. <pre>
  53. require 'mkmf'
  54. create_makefile('interface')
  55. </pre>
  56. </blockquote>
  57. <li>Type the following to build the extension:
  58. <blockquote>
  59. <pre>
  60. % ruby extconf.rb
  61. % make
  62. </pre>
  63. </blockquote>
  64. </ol>
  65. </ul>
  66. <h2>Compatibility</h2>
  67. The examples have been extensively tested on the following platforms:
  68. <ul>
  69. <li>Linux
  70. </ul>
  71. Your mileage may vary. If you experience a problem, please let us know by
  72. contacting us on the <a href="http://www.swig.org/mail.html">mailing lists</a>.
  73. </body>
  74. </html>