/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
2<head>
3<title>SWIG:Examples:ruby</title>
4</head>
5
6<body bgcolor="#ffffff">
7<H1>SWIG Ruby Examples</H1>
8
9<p>
10The following examples illustrate the use of SWIG with Ruby.
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, a global variable, and a constant.
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>. An example showing how to access C global variables from Ruby.
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>. Wrapping 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<li><a href="enum/index.html">enum</a>. Enumeration.
24</ul>
25
26<h2>Compilation Issues</h2>
27
28<ul>
29<li>To create a Ruby extension, SWIG is run with the following options:
30
31<blockquote>
32<pre>
33% swig -ruby interface.i
34</pre>
35</blockquote>
36
37<li>
38Please see the <a href="../../Doc/Manual/Windows.html">Windows</a> page in the main manual for information on using the examples on Windows. <p>
39</li>
40
41<li>On Unix the compilation of examples is done using the file <tt>Example/Makefile</tt>. This
42makefile performs a manual module compilation which is platform specific. Typically,
43the steps look like this (Linux):
44
45<blockquote>
46<pre>
47% swig -ruby interface.i
48% gcc -fpic -c interface_wrap.c -I/usr/local/lib/ruby/1.4/i686-linux
49% gcc -shared interface_wrap.o $(OBJS) -o interface.so
50% ruby
51require 'interface'
52Interface.blah(...)
53...
54</pre>
55</blockquote>
56
57<li>The politically "correct" way to compile a Ruby extension is to follow the steps
58described <tt>README.EXT</tt> in Ruby distribution:
59
60<p>
61<ol>
62<li>Create a file called <tt>extconf.rb</tt> that looks like the following:
63
64<blockquote>
65<pre>
66require 'mkmf'
67create_makefile('interface')
68</pre>
69</blockquote>
70<li>Type the following to build the extension:
71
72<blockquote>
73<pre>
74% ruby extconf.rb
75% make
76</pre>
77</blockquote>
78</ol>
79</ul>
80
81<h2>Compatibility</h2>
82
83The examples have been extensively tested on the following platforms:
84
85<ul>
86<li>Linux
87</ul>
88
89Your mileage may vary. If you experience a problem, please let us know by
90contacting us on the <a href="http://www.swig.org/mail.html">mailing lists</a>.
91</body>
92</html>
93
94