Updated documentation to reflect the -runtime and -noruntime commandline options for working with multiple modules / runtime library

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6024 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2004-07-10 16:39:31 +00:00
commit 41e9a9c984
7 changed files with 52 additions and 108 deletions

View file

@ -104,57 +104,25 @@ Unfortunately, this problem is inherent in the method by which SWIG makes module
<a name="n5"></a><H3>15.1.3 The SWIG runtime library</H3>
To reduce overhead and to fix type-handling problems, it is possible to share the SWIG run-time functions between multiple modules. This requires the use of the SWIG runtime library which is optionally built during SWIG installation. To use the runtime libraries, follow these steps:<p>
<p>
1. Build the SWIG run-time libraries.
The <tt>SWIG/Runtime</tt> directory contains a makefile for doing this for Unix users.
Some of the runtime libraries can also be built under Windows by following the instructions in the <a href="Windows.html">Windows</a> documentation.
If successfully built, you will end up with a number of files that are usually installed in <tt>/usr/local/lib</tt>.
The Perl, Python, Tcl and Ruby library files are listed below:<p>
<p>
<blockquote><pre>
libswigpl.a # Perl library (static)
libswigpl.so # Perl library (shared)
libswigpy.a # Python library (static)
libswigpy.so # Python library (shared)
libswigtcl8.a # Tcl 8.x library (static)
libswigtcl8.so # Tcl 8.x library (shared)
libswigrb.a # Ruby library (static)
libswigrb.so # Ruby library (shared)
</pre></blockquote>
<p>
Note that certain libraries may be missing due to missing packages or unsupported features (like dynamic loading) on your machine. Also some languages don't use the runtime libraries at all as they implement static type checking rather than dynamic type checking, for example, Java and C#.<p>
<p>
2. Compile all SWIG modules using the <tt>-c</tt> option. For example :<p>
<p>
<blockquote><pre>
% <b>swig -c -python a.i</b>
% <b>swig -c -python b.i</b>
</pre></blockquote>
The <tt>-c</tt> option tells SWIG to omit runtime support. It's now up to you to provide it separately--which we will do using our libraries.<p>
<p>
3. Build SWIG modules by linking against the appropriate runtime libraries.<p>
<p>
<blockquote><pre>
% <b>swig -c -python a.i</b>
% <b>swig -c -python b.i</b>
% <b>gcc -c a_wrap.c b_wrap.c -I/usr/local/include</b>
% <b>ld -shared a_wrap.o b_wrap.o -lswigpy -o a.so</b>
To reduce overhead and to fix type-handling problems, it is possible to share the SWIG run-time functions between multiple modules.
The <a href="#Modules.html">Working with Modules</a> chapter describes this in further detail and how to build the SWIG runtime library. The steps can be summarised as follows:
</pre></blockquote>
or if building a new executable (static linking)<p>
<p>
<blockquote><pre>
% <b>swig -c -tcl -ltclsh.i a.i</b>
% <b>gcc a_wrap.c -I/usr/local/include -L/usr/local/lib -ltcl -lswigtcl8 -lm -o mytclsh</b>
<ul>
<li> Build the SWIG run-time libraries. </li>
<li> Compile all SWIG modules using the <tt>-noruntime</tt> option. </li>
<li> Build SWIG modules by linking against the appropriate runtime libraries. </li>
</ul>
</pre></blockquote>
<p>
When completed you should now end up with a collection of modules like this:<p>
<center><img src="ch11.3.png"></center><p>
<p>
<p>
In this configuration, the runtime library manages all datatypes and other information between modules. This management process is dynamic in nature--when new modules are loaded, they contribute information to the run-time system. In the C++ world, one could incrementally load classes as needed. As this process occurs, type information is updated and base-classes learn about derived classes as needed.<p>
<p>
<b>Compatibility Note:</b> In SWIG-1.3.19 and earlier releases, SWIG built the runtime libraries by default and attempted to install them with the SWIG installation. This had numerous limitations, not least, the version of the target language was tied to what was detected at installation time and would not necessarily be the version the user required.
<a name="n6"></a><H3>15.1.4 A few dynamic loading gotchas</H3>
@ -361,6 +329,6 @@ As a rule of thumb, C++ programs require somewhat more processing than C progra
<p><hr>
<address>SWIG 1.1 - Last Modified : Mon Aug 4 10:47:13 1997</address>
<address>SWIG 1.3 - Last Modified : July 9, 2004</address>
</body>
</html>
</html>