Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <title>Getting started on Windows</title> | |
5 | <link rel="stylesheet" type="text/css" href="style.css"> | |
6 | </head> | |
7 | ||
8 | <body bgcolor="#ffffff"> | |
9 | <H1><a name="Windows"></a>3 Getting started on Windows </H1> | |
10 | <!-- INDEX --> | |
11 | <div class="sectiontoc"> | |
12 | <ul> | |
13 | <li><a href="#Windows_nn2">Installation on Windows</a> | |
14 | <ul> | |
15 | <li><a href="#Windows_nn3">Windows Executable</a> | |
16 | </ul> | |
17 | <li><a href="#examples">SWIG Windows Examples</a> | |
18 | <ul> | |
19 | <li><a href="#Windows_nn5">Instructions for using the Examples with Visual Studio</a> | |
20 | <ul> | |
21 | <li><a href="#Windows_nn6">Python</a> | |
22 | <li><a href="#Windows_nn7">TCL</a> | |
23 | <li><a href="#Windows_nn8">Perl</a> | |
24 | <li><a href="#Windows_nn9">Java</a> | |
25 | <li><a href="#Windows_nn10">Ruby</a> | |
26 | <li><a href="#Windows_nn11">C#</a> | |
27 | </ul> | |
28 | <li><a href="#Windows_nn12">Instructions for using the Examples with other compilers</a> | |
29 | </ul> | |
30 | <li><a href="#Windows_nn13">SWIG on Cygwin and MinGW</a> | |
31 | <ul> | |
32 | <li><a href="#swig_exe">Building swig.exe on Windows</a> | |
33 | <ul> | |
34 | <li><a href="#Windows_nn15">Building swig.exe using MinGW and MSYS</a> | |
35 | <li><a href="#Windows_nn16">Building swig.exe using Cygwin</a> | |
36 | <li><a href="#Windows_nn17">Building swig.exe alternatives</a> | |
37 | </ul> | |
38 | <li><a href="#examples_cygwin">Running the examples on Windows using Cygwin</a> | |
39 | </ul> | |
40 | </ul> | |
41 | </div> | |
42 | <!-- INDEX --> | |
43 | ||
44 | ||
45 | ||
46 | <p> | |
47 | This chapter describes SWIG usage on Microsoft Windows. | |
48 | Installing SWIG and running the examples is covered as well as building the SWIG executable. | |
49 | Usage within the Unix like environments MinGW and Cygwin is also detailed. | |
50 | </p> | |
51 | ||
52 | ||
53 | <H2><a name="Windows_nn2"></a>3.1 Installation on Windows</H2> | |
54 | ||
55 | ||
56 | <p> | |
57 | SWIG does not come with the usual Windows type installation program, however it is quite easy to get started. The main steps are: | |
58 | </p> | |
59 | <ul> | |
60 | <li>Download the swigwin zip package from the <a href="http://www.swig.org">SWIG website</a> and unzip into a directory. This is all that needs downloading for the Windows platform. | |
61 | <li>Set environment variables as described in the <a href="#examples">SWIG Windows Examples</a> section in order to run examples using Visual C++. | |
62 | </ul> | |
63 | ||
64 | <H3><a name="Windows_nn3"></a>3.1.1 Windows Executable</H3> | |
65 | ||
66 | ||
67 | <p> | |
68 | The swigwin distribution contains the SWIG Windows executable, swig.exe, which will run on 32 bit versions of Windows, ie Windows 95/98/ME/NT/2000/XP. | |
69 | If you want to build your own swig.exe have a look at <a href="#swig_exe">Building swig.exe on Windows</a>. | |
70 | </p> | |
71 | ||
72 | ||
73 | <H2><a name="examples"></a>3.2 SWIG Windows Examples</H2> | |
74 | ||
75 | ||
76 | <p> | |
77 | Using Microsoft Visual C++ is the most common approach to compiling and linking SWIG's output. | |
78 | The Examples directory has a few Visual C++ project files (.dsp files). | |
79 | These were produced by Visual C++ 6, although they should also work in Visual C++ 5. | |
80 | Later versions of Visual Studio should also be able to open and convert these project files. | |
81 | The C# examples come with .NET 2003 solution (.sln) and project files instead of Visual C++ 6 project files. | |
82 | The project files have been set up to execute SWIG in a custom build rule for the SWIG interface (.i) file. | |
83 | Alternatively run the <a href="#examples_cygwin">examples using Cygwin</a>. | |
84 | ||
85 | <p> | |
86 | More information on each of the examples is available with the examples distributed with SWIG (Examples/index.html). | |
87 | ||
88 | <H3><a name="Windows_nn5"></a>3.2.1 Instructions for using the Examples with Visual Studio</H3> | |
89 | ||
90 | ||
91 | <p> | |
92 | Ensure the SWIG executable is as supplied in the SWIG root directory in order for the examples to work. | |
93 | Most languages require some environment variables to be set <b>before</b> running Visual C++. | |
94 | Note that Visual C++ must be re-started to pick up any changes in environment variables. | |
95 | Open up an example .dsp file, Visual C++ will create a workspace for you (.dsw file). | |
96 | Ensure the Release build is selected then do a Rebuild All from the Build menu. | |
97 | The required environment variables are displayed with their current values. | |
98 | </p> | |
99 | <p> | |
100 | The list of required environment variables for each module language is also listed below. | |
101 | They are usually set from the Control Panel and System properties, but this depends on which flavour of Windows you are running. | |
102 | 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. | |
103 | If you are interested in how the project files are set up there is explanatory information in some of the language module's documentation. | |
104 | </p> | |
105 | ||
106 | <H4><a name="Windows_nn6"></a>3.2.1.1 Python</H4> | |
107 | ||
108 | ||
109 | <p> | |
110 | <b><tt>PYTHON_INCLUDE</tt></b> : Set this to the directory that contains python.h<br> | |
111 | <b><tt>PYTHON_LIB</tt></b> : Set this to the python library including path for linking<p> | |
112 | Example using Python 2.1.1:<br> | |
113 | <tt> | |
114 | PYTHON_INCLUDE: d:\python21\include<br> | |
115 | PYTHON_LIB: d:\python21\libs\python21.lib<br> | |
116 | </tt> | |
117 | </p> | |
118 | ||
119 | <H4><a name="Windows_nn7"></a>3.2.1.2 TCL</H4> | |
120 | ||
121 | ||
122 | <p> | |
123 | <b><tt>TCL_INCLUDE</tt></b> : Set this to the directory containing tcl.h<br> | |
124 | <b><tt>TCL_LIB</tt></b> : Set this to the TCL library including path for linking<p> | |
125 | Example using ActiveTcl 8.3.3.3 <br> | |
126 | <tt> | |
127 | TCL_INCLUDE: d:\tcl\include<br> | |
128 | TCL_LIB: d:\tcl\lib\tcl83.lib<br> | |
129 | </tt> | |
130 | </p> | |
131 | ||
132 | <H4><a name="Windows_nn8"></a>3.2.1.3 Perl</H4> | |
133 | ||
134 | ||
135 | <p> | |
136 | <b><tt>PERL5_INCLUDE</tt></b> : Set this to the directory containing perl.h<br> | |
137 | <b><tt>PERL5_LIB</tt></b> : Set this to the Perl library including path for linking<p> | |
138 | Example using nsPerl 5.004_04:<p> | |
139 | <tt> | |
140 | PERL5_INCLUDE: D:\nsPerl5.004_04\lib\CORE<br> | |
141 | PERL5_LIB: D:\nsPerl5.004_04\lib\CORE\perl.lib<br> | |
142 | </tt> | |
143 | </p> | |
144 | ||
145 | <H4><a name="Windows_nn9"></a>3.2.1.4 Java</H4> | |
146 | ||
147 | ||
148 | <p> | |
149 | <b><tt>JAVA_INCLUDE</tt></b> : Set this to the directory containing jni.h<br> | |
150 | <b><tt>JAVA_BIN</tt></b> : Set this to the bin directory containing javac.exe<p> | |
151 | Example using JDK1.3:<br> | |
152 | <tt> | |
153 | JAVA_INCLUDE: d:\jdk1.3\include<br> | |
154 | JAVA_BIN: d:\jdk1.3\bin<br> | |
155 | </tt> | |
156 | </p> | |
157 | ||
158 | <H4><a name="Windows_nn10"></a>3.2.1.5 Ruby</H4> | |
159 | ||
160 | ||
161 | <p> | |
162 | <b><tt>RUBY_INCLUDE</tt></b> : Set this to the directory containing ruby.h<br> | |
163 | <b><tt>RUBY_LIB</tt></b> : Set this to the ruby library including path for linking<p> | |
164 | Example using Ruby 1.6.4:<br> | |
165 | <tt> | |
166 | RUBY_INCLUDE: D:\ruby\lib\ruby\1.6\i586-mswin32<br> | |
167 | RUBY_LIB: D:\ruby\lib\mswin32-ruby16.lib<br> | |
168 | </tt> | |
169 | </p> | |
170 | ||
171 | <H4><a name="Windows_nn11"></a>3.2.1.6 C#</H4> | |
172 | ||
173 | ||
174 | <p> | |
175 | The C# examples do not require any environment variables to be set as a C# project file is included. | |
176 | Just open up the .sln solution file in Visual Studio .NET 2003 and do a Rebuild All from the Build menu. | |
177 | The accompanying C# and C++ project file are automatically used by the solution file. | |
178 | </p> | |
179 | ||
180 | <H3><a name="Windows_nn12"></a>3.2.2 Instructions for using the Examples with other compilers</H3> | |
181 | ||
182 | ||
183 | <p> | |
184 | 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. | |
185 | </p> | |
186 | ||
187 | <H2><a name="Windows_nn13"></a>3.3 SWIG on Cygwin and MinGW</H2> | |
188 | ||
189 | ||
190 | <p> | |
191 | 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. | |
192 | </p> | |
193 | ||
194 | <H3><a name="swig_exe"></a>3.3.1 Building swig.exe on Windows</H3> | |
195 | ||
196 | ||
197 | <p> | |
198 | If you want to replicate the build of swig.exe that comes with the download, follow the MinGW instructions below. | |
199 | This is not necessary to use the supplied swig.exe. | |
200 | This information is provided for those that want to modify the SWIG source code in a Windows environment. | |
201 | Normally this is not needed, so most people will want to ignore this section. | |
202 | </p> | |
203 | ||
204 | <H4><a name="Windows_nn15"></a>3.3.1.1 Building swig.exe using MinGW and MSYS</H4> | |
205 | ||
206 | ||
207 | <ul> | |
208 | <li>Install MinGW and MSYS from the <a href="http://www.mingw.org">MinGW</a> site. This provides a Unix environment on Windows. | |
209 | <li>Follow the usual Unix instructions in the README file in the SWIG root directory to build swig.exe from the MinGW command prompt. | |
210 | </ul> | |
211 | ||
212 | ||
213 | <H4><a name="Windows_nn16"></a>3.3.1.2 Building swig.exe using Cygwin</H4> | |
214 | ||
215 | ||
216 | <p> | |
217 | Note that SWIG can also be built using Cygwin. | |
218 | However, the SWIG will then require the Cygwin DLL when executing. | |
219 | Follow the Unix instructions in the README file in the SWIG root directory. | |
220 | Note that the Cygwin environment will also allow one to regenerate the autotool generated files which are supplied with the release distribution. | |
221 | These files are generated using the <tt>autogen.sh</tt> script and will only need regenerating in circumstances such as changing the build system. | |
222 | </p> | |
223 | ||
224 | <H4><a name="Windows_nn17"></a>3.3.1.3 Building swig.exe alternatives</H4> | |
225 | ||
226 | ||
227 | <p> | |
228 | If you don't want to install Cygwin or MinGW, use a different compiler to build | |
229 | SWIG. For example, all the source code files can be added to a Visual C++ project | |
230 | file in order to build swig.exe from the Visual C++ IDE. | |
231 | </p> | |
232 | ||
233 | ||
234 | <H3><a name="examples_cygwin"></a>3.3.2 Running the examples on Windows using Cygwin</H3> | |
235 | ||
236 | ||
237 | <p> | |
238 | The examples and test-suite work as successfully on Cygwin as on any other Unix operating system. | |
239 | The modules which are known to work are Python, Tcl, Perl, Ruby, Java and C#. | |
240 | Follow the Unix instructions in the README file in the SWIG root directory to build the examples. | |
241 | </p> | |
242 | ||
243 | </body> | |
244 | </html> |