How to install SWIG?

2020-02-12 01:21发布

问题:

Noob question ahead...

I'm trying to install SWIG on Windows. According to the INSTALL document, I have to

cd to the directory containing the package's source code and type ./configure to configure the package for your system.

I tried the command in both the root directory and in the /CCache directory (these are the only ones that have the configure and configure.in files), however, the shell reports back that

C:\swigwin-2.0.4>./configure
'.' is not recognized as an internal or external command,
operable program or batch file.

What am I missing?

回答1:

The page http://www.swig.org/download.html has a specific download for Windows with a pre-built version of swig.exe. You can download it and avoid the hassle of compiling swig by yourself.

If you really need to, you can consult the file Doc/Manual/Windows.html that contain Windows-specific instructions to build SWIG.

Finally, to answer your specific question, the syntax

./configure

is a UNIX-style command that means 'execute the program named configure in the current directory' (the dot)

On Windows, you would type

.\configure

or even simpler, as all files are executable on Windows, only

configure

... BUT this will not work as the said 'configure' script is a bash script that will not run in a Windows shell.



回答2:

no installation is needed. you just have to set the environment variable to point to the "swig" 's executable which is under the root directory of swig

On the SWIG site, you can download for example the swigwin-2.0.7 zip directory for windows's swig. unzip it in a directory of your choice for example on "C:\Program Files" directory if you want. After this, you have the swig executable in the "C:\Program Files\swigwin-2.0.7" directory: "C\Program Files\swigwin-2.0.7\swig" you have to set now the environment variable "path" to point to this swig exec: add for this the "C:\Program Files\swigwin-2.0.7" path to the "path"variable according to my example; that is all you need to use swig on windows. You can now play with swig so, open a prompt "cmd" and just type "swig --help" on this prompt you can see a list of the differents options you can use with swig. If you d'ont have visual c++, you can use for example codeblock, that is my case so the link below could be a help for you : http://wiki.codeblocks.org/index.phptitle=Adding_support_for_non_C/C%2B%2B_files_to_the_build_system



回答3:

Download Miniconda.

Then follow this guide and do: conda install -c anaconda swig