updates for R

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10163 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2007-11-22 23:55:34 +00:00
commit 83a741c35e
6 changed files with 115 additions and 89 deletions

View file

@ -57,32 +57,33 @@
<!-- INDEX -->
<div class="sectiontoc">
<ul>
<li><a href="Windows.html#Windows_nn2">Installation on Windows</a>
<li><a href="Windows.html#Windows_installation">Installation on Windows</a>
<ul>
<li><a href="Windows.html#Windows_nn3">Windows Executable</a>
<li><a href="Windows.html#Windows_executable">Windows Executable</a>
</ul>
<li><a href="Windows.html#examples">SWIG Windows Examples</a>
<li><a href="Windows.html#Windows_examples">SWIG Windows Examples</a>
<ul>
<li><a href="Windows.html#Windows_nn5">Instructions for using the Examples with Visual Studio</a>
<li><a href="Windows.html#Windows_visual_studio">Instructions for using the Examples with Visual Studio</a>
<ul>
<li><a href="Windows.html#Windows_nn6">Python</a>
<li><a href="Windows.html#Windows_nn7">TCL</a>
<li><a href="Windows.html#Windows_nn8">Perl</a>
<li><a href="Windows.html#Windows_nn9">Java</a>
<li><a href="Windows.html#Windows_nn10">Ruby</a>
<li><a href="Windows.html#Windows_nn11">C#</a>
<li><a href="Windows.html#Windows_csharp">C#</a>
<li><a href="Windows.html#Windows_java">Java</a>
<li><a href="Windows.html#Windows_perl">Perl</a>
<li><a href="Windows.html#Windows_python">Python</a>
<li><a href="Windows.html#Windows_tcl">TCL</a>
<li><a href="Windows.html#Windows_r">R</a>
<li><a href="Windows.html#Windows_ruby">Ruby</a>
</ul>
<li><a href="Windows.html#Windows_nn12">Instructions for using the Examples with other compilers</a>
<li><a href="Windows.html#Windows_other_compilers">Instructions for using the Examples with other compilers</a>
</ul>
<li><a href="Windows.html#Windows_nn13">SWIG on Cygwin and MinGW</a>
<li><a href="Windows.html#Windows_cygwin_mingw">SWIG on Cygwin and MinGW</a>
<ul>
<li><a href="Windows.html#swig_exe">Building swig.exe on Windows</a>
<li><a href="Windows.html#Windows_swig_exe">Building swig.exe on Windows</a>
<ul>
<li><a href="Windows.html#Windows_mingw_msys">Building swig.exe using MinGW and MSYS</a>
<li><a href="Windows.html#Windows_nn16">Building swig.exe using Cygwin</a>
<li><a href="Windows.html#Windows_nn17">Building swig.exe alternatives</a>
<li><a href="Windows.html#Windows_cygwin">Building swig.exe using Cygwin</a>
<li><a href="Windows.html#Windows_building_alternatives">Building swig.exe alternatives</a>
</ul>
<li><a href="Windows.html#examples_cygwin">Running the examples on Windows using Cygwin</a>
<li><a href="Windows.html#Windows_examples_cygwin">Running the examples on Windows using Cygwin</a>
</ul>
<li><a href="Windows.html#Windows_interface_file">Microsoft extensions and other Windows quirks</a>
</ul>
@ -484,6 +485,7 @@
<!-- INDEX -->
<div class="sectiontoc">
<ul>
<li><a href="Modules.html#Modules_nn1">Basics</a>
<li><a href="Modules.html#Modules_nn2">The SWIG runtime code</a>
<li><a href="Modules.html#external_run_time">External access to the runtime</a>
<li><a href="Modules.html#Modules_nn4">A word of caution about static libraries</a>

View file

@ -37,7 +37,8 @@ This chapter describes the problem of using SWIG in programs
where you want to create a collection of modules.
</p>
<h2><a name="Modules_nn1"></a>15.1 Basics</h2>
<H2><a name="Modules_nn1"></a>15.1 Basics</H2>
<p>
The basic usage case with multiple modules is when modules do not have
@ -87,6 +88,7 @@ issue, read on.</p>
<H2><a name="Modules_nn2"></a>15.2 The SWIG runtime code</H2>
<p>
Many of SWIG's target languages generate a set of functions commonly known as
the "SWIG runtime." These functions are primarily related to the runtime type
@ -150,7 +152,7 @@ can peacefully coexist. So the type structures are separated by the
is empty. Only modules compiled with the same pair will share type information.
</p>
<H2><a name="external_run_time"></a>15.2 External access to the runtime</H2>
<H2><a name="external_run_time"></a>15.3 External access to the runtime</H2>
<p>As described in <a href="Typemaps.html#runtime_type_checker">The run-time type checker</a>,
@ -187,7 +189,7 @@ SWIG_TYPE_TABLE to be the same as the module whose types you are trying to
access.
</p>
<H2><a name="Modules_nn4"></a>15.3 A word of caution about static libraries</H2>
<H2><a name="Modules_nn4"></a>15.4 A word of caution about static libraries</H2>
<p>
@ -198,7 +200,7 @@ into it. This is very often <b>NOT</b> what you want and it can lead to unexpect
behavior. When working with dynamically loadable modules, you should try to work exclusively with shared libraries.
</p>
<H2><a name="Modules_nn5"></a>15.4 References</H2>
<H2><a name="Modules_nn5"></a>15.5 References</H2>
<p>
@ -206,7 +208,7 @@ Due to the complexity of working with shared libraries and multiple modules, it
an outside reference. John Levine's "Linkers and Loaders" is highly recommended.
</p>
<H2><a name="Modules_nn6"></a>15.5 Reducing the wrapper file size</H2>
<H2><a name="Modules_nn6"></a>15.6 Reducing the wrapper file size</H2>
<p>

View file

@ -116,6 +116,7 @@ command line argument to swig may be of use - see below for details.
<H3><a name="Php_nn1_1"></a>27.1.1 Building a loadable extension</H3>
<p>
To build your module as a dynamically loadable extension, use compilation
commands like these (if you aren't using GCC, the commands will be different,
@ -139,6 +140,7 @@ you don't use <tt>-make</tt> and it's likely to be removed at some point.
<H3><a name="Php_nn1_2"></a>27.1.2 Building extensions into PHP</H3>
<p>
Note that we don't recommend this approach - it's cleaner and simpler to
use dynamically loadable modules, which are supported by all modern OSes.

View file

@ -30,7 +30,7 @@ href="http://www.r-project.org/">www.r-project.org</a>.
The R bindings are under active development. They have been used to
compile and run an R interface to QuantLib running on Mandriva Linux
with gcc, and testing on other platforms is appreciated.
with gcc. The R bindings also work on Microsoft Windows using Visual C++.
</p>
<H2><a name="R_nn2"></a>32.1 Bugs</H2>
@ -43,7 +43,6 @@ Currently the following features are not implemented or broken:
<ul>
<li>Garbage collection of created objects
<li>C Array wrappings
<li>tested on UNIX only, how well or badly it works on windows is not known
</ul>
<H2><a name="R_nn3"></a>32.2 Using R and SWIG</H2>
@ -67,7 +66,7 @@ The corresponding comments for C++ mode are
<div class="shell">
<pre>
swig -c++ -r example.i
swig -c++ -r -o example_wrap.cpp example.i
PKG_LIBS="example.cxx" R CMD SHLIB example_wrap.cpp
</pre>
</div>
@ -75,20 +74,20 @@ PKG_LIBS="example.cxx" R CMD SHLIB example_wrap.cpp
<p>
Note that R is sensitive to the name of the file and to the file
extension in C and C++ mode. The name of the wrapper file must be the
name of the library. Also in C++ mode, the file extension must be cpp
rather than cxx for the R compile command to recognize it.
name of the library. Also in C++ mode, the file extension must be .cpp
rather than .cxx for the R compile command to recognize it.
</p>
<p>
The commands produces two files. A dynamic shared object file called
example_wrap.so and an R wrapper file called example_wrap.R. To load these
example.so, or example.dll, and an R wrapper file called example.R. To load these
files, start up R and type in the following commands
</p>
<div class="shell">
<pre>
dyn.load('example_wrap.so')
source('example_wrap.R')
dyn.load(paste("example", .Platform$dynlib.ext, sep=""))
source("example.R")
cacheMetaData(1)
</pre>
</div>
@ -108,12 +107,12 @@ time by precompiling the R wrapper. This can be done by creating the
file makeRData.R which contains the following
<pre>
source('BigFile_wrap.R')
save(list=ls(all=TRUE),file="BigFile_wrap.RData", compress=TRUE)
source('BigFile.R')
save(list=ls(all=TRUE),file="BigFile.RData", compress=TRUE)
q(save="no")
</pre>
This will generate a compiled R file called BigFile_wrap.RData that
This will generate a compiled R file called BigFile.RData that
will save a large amount of loading time.

View file

@ -6,7 +6,7 @@
<body bgcolor="#ffffff">
<H1><a name="Sections"></a>SWIG-1.3 Development Documentation</H1>
Last update : SWIG-1.3.33 (in progress)
Last update : SWIG-1.3.33 (November 23, 2007)
<H2>Sections</H2>

View file

@ -10,32 +10,33 @@
<!-- INDEX -->
<div class="sectiontoc">
<ul>
<li><a href="#Windows_nn2">Installation on Windows</a>
<li><a href="#Windows_installation">Installation on Windows</a>
<ul>
<li><a href="#Windows_nn3">Windows Executable</a>
<li><a href="#Windows_executable">Windows Executable</a>
</ul>
<li><a href="#examples">SWIG Windows Examples</a>
<li><a href="#Windows_examples">SWIG Windows Examples</a>
<ul>
<li><a href="#Windows_nn5">Instructions for using the Examples with Visual Studio</a>
<li><a href="#Windows_visual_studio">Instructions for using the Examples with Visual Studio</a>
<ul>
<li><a href="#Windows_nn6">Python</a>
<li><a href="#Windows_nn7">TCL</a>
<li><a href="#Windows_nn8">Perl</a>
<li><a href="#Windows_nn9">Java</a>
<li><a href="#Windows_nn10">Ruby</a>
<li><a href="#Windows_nn11">C#</a>
<li><a href="#Windows_csharp">C#</a>
<li><a href="#Windows_java">Java</a>
<li><a href="#Windows_perl">Perl</a>
<li><a href="#Windows_python">Python</a>
<li><a href="#Windows_tcl">TCL</a>
<li><a href="#Windows_r">R</a>
<li><a href="#Windows_ruby">Ruby</a>
</ul>
<li><a href="#Windows_nn12">Instructions for using the Examples with other compilers</a>
<li><a href="#Windows_other_compilers">Instructions for using the Examples with other compilers</a>
</ul>
<li><a href="#Windows_nn13">SWIG on Cygwin and MinGW</a>
<li><a href="#Windows_cygwin_mingw">SWIG on Cygwin and MinGW</a>
<ul>
<li><a href="#swig_exe">Building swig.exe on Windows</a>
<li><a href="#Windows_swig_exe">Building swig.exe on Windows</a>
<ul>
<li><a href="#Windows_mingw_msys">Building swig.exe using MinGW and MSYS</a>
<li><a href="#Windows_nn16">Building swig.exe using Cygwin</a>
<li><a href="#Windows_nn17">Building swig.exe alternatives</a>
<li><a href="#Windows_cygwin">Building swig.exe using Cygwin</a>
<li><a href="#Windows_building_alternatives">Building swig.exe alternatives</a>
</ul>
<li><a href="#examples_cygwin">Running the examples on Windows using Cygwin</a>
<li><a href="#Windows_examples_cygwin">Running the examples on Windows using Cygwin</a>
</ul>
<li><a href="#Windows_interface_file">Microsoft extensions and other Windows quirks</a>
</ul>
@ -51,7 +52,7 @@ Usage within the Unix like environments MinGW and Cygwin is also detailed.
</p>
<H2><a name="Windows_nn2"></a>3.1 Installation on Windows</H2>
<H2><a name="Windows_installation"></a>3.1 Installation on Windows</H2>
<p>
@ -62,7 +63,7 @@ SWIG does not come with the usual Windows type installation program, however it
<li>Set environment variables as described in the <a href="#examples">SWIG Windows Examples</a> section in order to run examples using Visual C++.
</ul>
<H3><a name="Windows_nn3"></a>3.1.1 Windows Executable</H3>
<H3><a name="Windows_executable"></a>3.1.1 Windows Executable</H3>
<p>
@ -71,7 +72,7 @@ If you want to build your own swig.exe have a look at <a href="#swig_exe">Buildi
</p>
<H2><a name="examples"></a>3.2 SWIG Windows Examples</H2>
<H2><a name="Windows_examples"></a>3.2 SWIG Windows Examples</H2>
<p>
@ -86,7 +87,7 @@ Alternatively run the <a href="#examples_cygwin">examples using Cygwin</a>.
<p>
More information on each of the examples is available with the examples distributed with SWIG (Examples/index.html).
<H3><a name="Windows_nn5"></a>3.2.1 Instructions for using the Examples with Visual Studio</H3>
<H3><a name="Windows_visual_studio"></a>3.2.1 Instructions for using the Examples with Visual Studio</H3>
<p>
@ -104,33 +105,31 @@ If you don't want to use environment variables then change all occurrences of th
If you are interested in how the project files are set up there is explanatory information in some of the language module's documentation.
</p>
<H4><a name="Windows_nn6"></a>3.2.1.1 Python</H4>
<H4><a name="Windows_csharp"></a>3.2.1.1 C#</H4>
<p>
<b><tt>PYTHON_INCLUDE</tt></b> : Set this to the directory that contains python.h<br>
<b><tt>PYTHON_LIB</tt></b> : Set this to the python library including path for linking<p>
Example using Python 2.1.1:<br>
<tt>
PYTHON_INCLUDE: d:\python21\include<br>
PYTHON_LIB: d:\python21\libs\python21.lib<br>
</tt>
The C# examples do not require any environment variables to be set as a C# project file is included.
Just open up the .sln solution file in Visual Studio .NET 2003 or later, select Release Build, and do a Rebuild All from the Build menu.
The accompanying C# and C++ project files are automatically used by the solution file.
</p>
<H4><a name="Windows_nn7"></a>3.2.1.2 TCL</H4>
<H4><a name="Windows_java"></a>3.2.1.2 Java</H4>
<p>
<b><tt>TCL_INCLUDE</tt></b> : Set this to the directory containing tcl.h<br>
<b><tt>TCL_LIB</tt></b> : Set this to the TCL library including path for linking<p>
Example using ActiveTcl 8.3.3.3 <br>
<b><tt>JAVA_INCLUDE</tt></b> : Set this to the directory containing jni.h<br>
<b><tt>JAVA_BIN</tt></b> : Set this to the bin directory containing javac.exe<p>
Example using JDK1.3:<br>
<tt>
TCL_INCLUDE: d:\tcl\include<br>
TCL_LIB: d:\tcl\lib\tcl83.lib<br>
JAVA_INCLUDE: D:\jdk1.3\include<br>
JAVA_BIN: D:\jdk1.3\bin<br>
</tt>
</p>
<H4><a name="Windows_nn8"></a>3.2.1.3 Perl</H4>
<H4><a name="Windows_perl"></a>3.2.1.3 Perl</H4>
<p>
@ -143,20 +142,50 @@ PERL5_LIB: D:\nsPerl5.004_04\lib\CORE\perl.lib<br>
</tt>
</p>
<H4><a name="Windows_nn9"></a>3.2.1.4 Java</H4>
<H4><a name="Windows_python"></a>3.2.1.4 Python</H4>
<p>
<b><tt>JAVA_INCLUDE</tt></b> : Set this to the directory containing jni.h<br>
<b><tt>JAVA_BIN</tt></b> : Set this to the bin directory containing javac.exe<p>
Example using JDK1.3:<br>
<b><tt>PYTHON_INCLUDE</tt></b> : Set this to the directory that contains python.h<br>
<b><tt>PYTHON_LIB</tt></b> : Set this to the python library including path for linking<p>
Example using Python 2.1.1:<br>
<tt>
JAVA_INCLUDE: d:\jdk1.3\include<br>
JAVA_BIN: d:\jdk1.3\bin<br>
PYTHON_INCLUDE: D:\python21\include<br>
PYTHON_LIB: D:\python21\libs\python21.lib<br>
</tt>
</p>
<H4><a name="Windows_nn10"></a>3.2.1.5 Ruby</H4>
<H4><a name="Windows_tcl"></a>3.2.1.5 TCL</H4>
<p>
<b><tt>TCL_INCLUDE</tt></b> : Set this to the directory containing tcl.h<br>
<b><tt>TCL_LIB</tt></b> : Set this to the TCL library including path for linking<p>
Example using ActiveTcl 8.3.3.3 <br>
<tt>
TCL_INCLUDE: D:\tcl\include<br>
TCL_LIB: D:\tcl\lib\tcl83.lib<br>
</tt>
</p>
<H4><a name="Windows_r"></a>3.2.1.6 R</H4>
<p>
<b><tt>R_INCLUDE</tt></b> : Set this to the directory containing R.h<br>
<b><tt>R_LIB</tt></b> : Set this to the R library (Rdll.lib) including path for linking. The library needs to be built as described in the R README.packages file (the pexports.exe approach is the easiest).<p>
Example using R 2.5.1:<br>
<tt>
R_INCLUDE: C:\Program Files\R\R-2.5.1\include<br>
R_LIB: C:\Program Files\R\R-2.5.1\bin\Rdll.lib<br>
</tt>
</p>
<H4><a name="Windows_ruby"></a>3.2.1.7 Ruby</H4>
<p>
@ -169,30 +198,22 @@ RUBY_LIB: D:\ruby\lib\mswin32-ruby16.lib<br>
</tt>
</p>
<H4><a name="Windows_nn11"></a>3.2.1.6 C#</H4>
<p>
The C# examples do not require any environment variables to be set as a C# project file is included.
Just open up the .sln solution file in Visual Studio .NET 2003 and do a Rebuild All from the Build menu.
The accompanying C# and C++ project file are automatically used by the solution file.
</p>
<H3><a name="Windows_nn12"></a>3.2.2 Instructions for using the Examples with other compilers</H3>
<H3><a name="Windows_other_compilers"></a>3.2.2 Instructions for using the Examples with other compilers</H3>
<p>
If you do not have access to Visual C++ you will have to set up project files / Makefiles for your chosen compiler. There is a section in each of the language modules detailing what needs setting up using Visual C++ which may be of some guidance. Alternatively you may want to use Cygwin as described in the following section.
</p>
<H2><a name="Windows_nn13"></a>3.3 SWIG on Cygwin and MinGW</H2>
<H2><a name="Windows_cygwin_mingw"></a>3.3 SWIG on Cygwin and MinGW</H2>
<p>
SWIG can also be compiled and run using <a href="http://www.cygwin.com">Cygwin</a> or <a href="http://www.mingw.org">MinGW</a> which provides a Unix like front end to Windows and comes free with gcc, an ANSI C/C++ compiler. However, this is not a recommended approach as the prebuilt executable is supplied.
</p>
<H3><a name="swig_exe"></a>3.3.1 Building swig.exe on Windows</H3>
<H3><a name="Windows_swig_exe"></a>3.3.1 Building swig.exe on Windows</H3>
<p>
@ -304,7 +325,7 @@ make
</ol>
<H4><a name="Windows_nn16"></a>3.3.1.2 Building swig.exe using Cygwin</H4>
<H4><a name="Windows_cygwin"></a>3.3.1.2 Building swig.exe using Cygwin</H4>
<p>
@ -315,7 +336,7 @@ Note that the Cygwin environment will also allow one to regenerate the autotool
These files are generated using the <tt>autogen.sh</tt> script and will only need regenerating in circumstances such as changing the build system.
</p>
<H4><a name="Windows_nn17"></a>3.3.1.3 Building swig.exe alternatives</H4>
<H4><a name="Windows_building_alternatives"></a>3.3.1.3 Building swig.exe alternatives</H4>
<p>
@ -325,7 +346,7 @@ file in order to build swig.exe from the Visual C++ IDE.
</p>
<H3><a name="examples_cygwin"></a>3.3.2 Running the examples on Windows using Cygwin</H3>
<H3><a name="Windows_examples_cygwin"></a>3.3.2 Running the examples on Windows using Cygwin</H3>
<p>