SWIG for Windows

Windows Executable

The SWIG windows executable comes as a separate download which can be obtained from the SWIG website.

SWIG can also be compiled and run using Cygwin which provides a Unix like front end to Windows.

SWIG Windows Examples

Using Microsoft Visual C++ is the most successful approach to compiling and linking SWIG's output. The Examples directory has a few Visual C++ project files (.dsp files). These were produced by Visual C++ 6, although they should also work in Visual C++ 5. These project files have been set up to use SWIG in a custom build for the SWIG interface (.i) file.

More information on each of the examples is available on the SWIG Examples page.

Instructions for using the Examples from Visual C++

Ensure the SWIG executable is unzipped and placed in the SWIG root directory for the examples to work. Each language requires some environmemnt variables to be set before opening Visual C++. Note that Visual C++ must be re-started to pick up any changes in environment variables. Open up the .dsp file, Visual C++ will create a workspace for you (.dsw file). Do a Rebuild All from the Build menu. The environment variables that need setting are displayed with their current values.

The list of required environment variables for each module language are listed below. They are usually set from the Control Panel and System properties, but this depends on which flavour of Windows you are running. If you don't want to use environment variables then change all occurences of the environment variables in the .dsp files with hard coded values.

Python

PYTHON_INCLUDE : Set this to the directory that contains python.h
PYTHON_LIB : Set this to the python library including path for linking with

Example using Python 2.1.1:
PYTHON_INCLUDE: d:\python21\include
PYTHON_LIB: d:\python21\libs\python21.lib

TCL

TCL_INCLUDE : Set this to the directory containing tcl.h
TCL_LIB : Set this to the TCL library including path for linking with

Example using ActiveTcl 8.3.3.3
TCL_INCLUDE: d:\tcl\include
TCL_LIB: d:\tcl\lib\tcl83.lib

Perl

PERL5_INCLUDE : Set this to the directory containing perl.h and perl.lib
Example using nsPerl 5.004_04:

PERL5_INCLUDE: D:\nsPerl5.004_04\lib\CORE

Java

JAVA_INCLUDE : Set this to the directory containing jni.h
JAVA_BIN : Set this to the bin directory containing javac.exe

Example using JDK1.3:
JAVA_INCLUDE: d:\jdk1.3\include
JAVA_BIN: d:\jdk1.3\bin

Ruby

RUBY_INCLUDE : Set this to the directory containing ruby.h
RUBY_LIB : Set this to the ruby library including path for linking with

Example using Ruby 1.6.4:
RUBY_INCLUDE: D:\ruby\lib\ruby\1.6\i586-mswin32
RUBY_LIB: D:\ruby\lib\mswin32-ruby16.lib