Installing DOLFIN on Windows
From The FEniCS project
Note: This guide is work in progress. Please send any feedback to dolfin-dev@fenics.org.
This guide shows you how to install DOLFIN on the Windows platform. Several software packages are required to be installed before we can install DOLFIN. First and foremost we need a C++ compiler (MinGW), SCons (and Python), and pkg-config. In addition we need UFC, Boost, libXML, and zlib. We also need Mercurial to access the latest hg repositories. For plotting, we need Viper and VTK, and to enable the Python interface to DOLFIN (optinal), we need to install SWIG and the numerical Python package NumPy. Finally, we will also install FIAT, FCC, and Instant. Below follows a short installation guide for each of these packages.
Installing MinGW
Download the latest version of the "Automated MinGW Installer" from mingw.org or download it directly from here (latest as of August 2008):
http://dl.sourceforge.net/sourceforge/mingw/MinGW-5.1.4.exe
Double-click on the file and follow the instructions. When asked to choose components, mark (at least) the following:
- MinGW base tools
- g++ compiler
- MinGW Make
Use the default when asked to choose install location:
C:\MinGW
Then add the bin folder to the PATH environment variable
You will probably run into trouble later when compiling DOLFIN with the g++-3.4 compiler that ships with the MinGW installer. Instead, download and install g++ 4.2 from the MinGW website, or use the following direct link:
http://dl.sourceforge.net/sourceforge/mingw/gcc-g++-4.2.1-sjlj-2.tar.gz
Extract the file (e.g. using 7-zip) to C:\MinGW or wherever you installed MinGW. Answer yes to overwrite files when asked. The 4.2 version of g++ should then be available as g++-sjlj. To make sure that the DOLFIN build system picks up this compiler later, add a new system variable called CXX with value g++-sjlj.
It is also necessary to download and extract the gcc 4.2 core files to the MinGW installation folder:
http://dl.sourceforge.net/sourceforge/mingw/gcc-core-4.2.1-sjlj-2.tar.gz
Installing MSYS
Some of the external packages will require MSYS to compile so you should install this as well. You can download the latest MSYS from the MinGW website or use the following direct link:
http://kent.dl.sourceforge.net/sourceforge/mingw/MSYS-1.0.10.exe
Double-click on the file and follow the instructions. Install into C:\msys\1.0. When you are asked about if you want to continue with the post installation, answer yes (type in y and hit enter). You will then be asked if you have installed MinGW. Answer yes and type in c:/mingw when asked about where MinGW is installed (note the forward slash and the lowercase letters in the path).
In addition to MSYS, you should also install the MSYS Developer Toolkit. You can find it at the MinGW website or you can download it directly by clicking on the following link:
http://dl.sourceforge.net/sourceforge/mingw/msysDTK-1.0.1.exe
Then, simply double-click and follow the defaults.
Installing Python
Go to python.org and download the latest Python release, or if you have an x86 processor, you can download the latest 32-bit binary (as of August 2008) directly by clicking here (requires MSI). Then double-click the icon and follow the instruction on the screen (the default values should be fine). Finally, add C:\Python25 (or wherever you chose to install Python) and C:\Python25\Scripts to the PATH environment variable.
Installing SCons
Download the latest version of SCons from scons.org. 32-bits users can use the following direct link:
http://dl.sourceforge.net/sourceforge/scons/scons-1.0.0.d20080826.win32.exe
Again, simply double-click and follow the instructions.
Installing pkg-config
The DOLFIN build system also requires the pkg-config tool to be installed. You may build pkg-config from source (see http://pkg-config.freedesktop.org) or download some prebuilt binaries from this location. Only the latter approach is explained here. Start by downloading pkg-config here and unzip it into a folder on your computer (e.g., C:\pkg-config). Make sure the bin folder is included in Windows' PATH variable. The pkg-config tool requires several DLL's such as libglib-2.0-0.dll (GLib), iconv.dll (Libiconv), and intl.dll (gettext). You may download these from the same website: here, here, and here. Extract the contents to some suitable folder (like C:\local) and make sure that the bin subfolder (C:\local\bin) is added to the system PATH variable.
Installing NumPy
Download the latest version of NumPy from numpy.scipy.org. Here is the link to the latest 32-bit self extracting Python installer (as of August 2008):
http://dl.sourceforge.net/sourceforge/numpy/numpy-1.1.0-win32-superpack-python2.5.exe
Simply execute the file by double-clicking on it and follow the instructions.
Installing Mercurial
Visit this website and download the latest Mercurial binary for Windows or use the following direct link:
http://mercurial.berkwood.com/binaries/Mercurial-1.0.1.exe
Double-click on the file and follow the instructions.
Installing SWIG
Download the latest release from swig.org or use the following direct link (includes prebuilt 32-bit binaries):
http://dl.sourceforge.net/sourceforge/swig/swigwin-1.3.36.zip
Unzip to a suitable location, e.g. C:\swigwin and add this folder to the PATH environment variable.
Installing Boost
Dolfin only requires the Boost header files.
http://dl.sourceforge.net/sourceforge/boost/boost_1_35_0.tar.gz
Extract the contents to a suitable folder and add a new environment variable BOOST_DIR that points to this folder, e.g., let BOOST_DIR be defined as
BOOST_DIR=c:\\boost_1_35_0
Note the double backslash.
Installing libXML
First we need to download and install pexport:
http://www.emmestech.com/software/pexports-0.43/pexports-0.43.zip
Unzip and add the bin folder to the PATH environment variable. Then, download the XML C parser libXML and the data compression library zlib. You can download precompiled Windows binaries (built by Igor Zlatovic) here or by using these direct links:
http://www.zlatkovic.com/pub/libxml/libxml2-2.6.32+.win32.zip http://www.zlatkovic.com/pub/libxml/zlib-1.2.3.win32.zip
Unzip both into some sutible location (e.g. C:\local). Then open up a command prompt and navigate to the bin subfolder of where you extracted the files, e.g.,
cd C:\local\bin
Now, type in the following two lines to create a static library for libXML (dlltool comes with MinGW):
pexports libxml2.dll > libxml2.def dlltool --dllname libxml2.dll --def libxml2.def --output-lib ..\lib\libxml2.a
Do the the same for zlib as well:
pexports zlib1.dll > zlib.def dlltool --dllname zlib1.dll --def zlib.def --output-lib ..\lib\zlib.a
Currently, the DOLFIN build system doesn't include a pkg-config generator for libXML so we have to create one manually. Here is a sample pkg-config file (modify it to match your installation paths):
Name: libXML Version: 2.6.32 Description: libXML library version 2. Libs: -LC:\\local\\lib -lxml2 Libs.private: -lz -lm Cflags: -IC:\\local\\include\\libxml
Save these lines in a file called libxml-2.0.pc and place it in a folder that is included in the PKG_CONFIG_PATH variable (e.g. C:\local\Lib\pkgconfig).
Installing UFC
First download the latest UFC. That is, open up a command prompt (cmd.exe) and navigate into a suitable folder (e.g. C:\src). Then enter the following:
hg clone http://www.fenics.org/hg/ufc
Navigate into the newly created folder
cd ufc
and install UFC by typing
python setup.py install --prefix=<prefix>
where <prefix> is substituted with some suitable prefix, e.g., C:\local. Add <prefix>\Lib\pkgconfig and <prefix>\Lib\site-packages to the PKG_CONFIG_PATH and the PYTHONPATH environment variables, respectively (you may need to create them if they doesn't exists).
Installing FFC
Open up a command prompt and type in the following to download and install the latest FFC:
cd C:\src hg clone http://www.fenics.org/hg/ffc cd ffc python setup.py install --prefix=C:\local
Installing FIAT
Open up a command prompt and type in the following to download and install the latest FIAT:
cd C:\src hg clone http://www.fenics.org/hg/fiat cd fiat python setup.py install --prefix=C:\local
Installing Instant
Open up a command prompt and type in the following to download and install the latest Instant:
cd C:\src hg clone http://www.fenics.org/hg/instant cd instant python setup.py install --prefix=C:\local
The Instant module creates Python extension modules and on Windows these will be compiled with MSVC by default. Instead, we want to build with the MinGW compilers, so open up the file C:\Python25\Lib\distutils\distutils.cfg (create it if it doesn't exists) and add the following:
[build] compiler=mingw32
See also this website.
Installing Viper
Open up a command prompt and type in the following to download and install the latest Viper:
cd C:\src hg clone http://www.fenics.org/hg/viper cd viper python setup.py install --prefix=C:\local
Viper also requires VTK (see below).
Installing CMake
Download CMake from cmake.org or use the following direct link (latest as of Aug 2008):
http://www.cmake.org/files/v2.6/cmake-2.6.1-win32-x86.exe
Doubleclick and follow the instructions. Choose to add CMake to system PATH for all/current user(s) when asked.
Installing CVS
Start by downloading CVS from the CVS website. Here is a direct link to the latest stable release (as of August 2008):
http://ftp.gnu.org/non-gnu/cvs/binary/stable/x86-woe/cvs-1-11-22.zip
The zip-file contains a 32-bit Windows executable cvs.exe. Unzip this file to a location in your PATH environment variable (e.g. C:\local\bin).
Installing VTK
Before you start installing VTK, make sure you have installed CMake and CVS (see above).
Open up a command prompt and navigate to some suitable location (for instance C:\src). Then, type in the following to get read access to the VTK CVS repository:
cvs -d :pserver:anonymous@public.kitware.com:/cvsroot/VTK login
Respond with `vtk` when asked for a password. You can then check out the source code by entering this command:
cvs -d :pserver:anonymous@public.kitware.com:/cvsroot/VTK checkout VTK
Open the file CMake/vtkTestTypes.cmake and search for this:
# Enable the "__int64" type if it is available and unique. It is not
# standard.
SET(VTK_TYPE_USE___INT64)
IF(VTK_SIZEOF___INT64)
IF(NOT VTK_TYPE_SAME_LONG_AND___INT64)
IF(NOT VTK_TYPE_SAME_LONG_LONG_AND___INT64)
SET(VTK_TYPE_USE___INT64 1)
ENDIF(NOT VTK_TYPE_SAME_LONG_LONG_AND___INT64)
ENDIF(NOT VTK_TYPE_SAME_LONG_AND___INT64)
ENDIF(VTK_SIZEOF___INT64)
Change this into
# Enable the "__int64" type if it is available and unique. It is not
# standard.
SET(VTK_TYPE_USE___INT64)
IF(VTK_SIZEOF___INT64)
IF(NOT VTK_TYPE_SAME_LONG_AND___INT64)
IF(NOT VTK_TYPE_SAME_LONG_LONG_AND___INT64)
SET(VTK_TYPE_USE___INT64 1)
ENDIF(NOT VTK_TYPE_SAME_LONG_LONG_AND___INT64)
ENDIF(NOT VTK_TYPE_SAME_LONG_AND___INT64)
ENDIF(VTK_SIZEOF___INT64)
SET(VTK_TYPE_USE___INT64 0)
That is, add SET(VTK_TYPE_USE___INT64 0) at the end.
Now, start up CMake and select the folder for where your VTK sources are located and where you want the to build the binaries, e.g., C:\src\VTK and C:\src\VTK-mingw, respectively. Then click on Configure and choose "MinGW Makefiles".
Change the following values from the default (click on Show Advanced Values):
BUILD_SHARED_LIBS: ON BUILD_TESTING: OFF CMAKE_BUILD_TYPE: Release VTK_WRAP_PYTHON: ON
Click on Configure again. You will probably get an error about that Tk was not found. In that case click on OK to close the error message. Then set VTK_USE_TK to off to fix this issue. Click on Configure twice. If there are no red values, click on OK to generate the Makefiles.
Open up a command prompt and navigate to the folder where you selected to build the binaries. Then, to start building VTK, simply type in
mingw32-make
When the build finishes (can take quite a while), you can install VTK by entering the following:
mingw32-make install
You may encounter the following (or similar) error:
error: can't copy 'C:\src\VTK-mingw\bin\vtkCommonPython.pyd': doesn't exist or not a regular file
In that case, you need strip of the leading 'lib' on all the .pyd files in the bin folder:
copy bin\libvtkCommonPython.pyd bin\vtkCommonPython.pyd copy bin\libvtkFilteringPython.pyd bin\vtkFilteringPython.pyd copy bin\libvtkGenericFilteringPython.pyd bin\vtkGenericFilteringPython.pyd copy bin\libvtkGeovisPython.pyd bin\vtkGeovisPython.pyd copy bin\libvtkGraphicsPython.pyd bin\vtkGraphicsPython.pyd copy bin\libvtkHybridPython.pyd bin\vtkHybridPython.pyd copy bin\libvtkImagingPython.pyd bin\vtkImagingPython.pyd copy bin\libvtkInfovisPython.pyd bin\vtkInfovisPython.pyd copy bin\libvtkIOPython.pyd bin\vtkIOPython.pyd copy bin\libvtkRenderingPython.pyd bin\vtkRenderingPython.pyd copy bin\libvtkViewsPython.pyd bin\vtkViewsPython.pyd copy bin\libvtkVolumeRenderingPython.pyd bin\vtkVolumeRenderingPython.pyd copy bin\libvtkWidgetsPython.pyd bin\vtkWidgetsPython.pyd
Then run mingw32-make install again.
Finally, add C:\Program Files\VTK\bin to the PATH environment variable. Also add C:\Program Files\VTK\lib\site-packages to the PYTHONPATH environment variable.
Installing SuiteSparse
Head over to the SuiteSparse website and download the latest release. Here is a direct link to the latest as of August 2008:
http://www.cise.ufl.edu/research/sparse/SuiteSparse/current/SuiteSparse.tar.gz
Unpack the archive to a suitable folder, like C:\src.
To be written ...
Installing DOLFIN
We should now be ready to build DOLFIN. From a command prompt, navigate to a suitable folder, e.g.,
cd C:\src
and clone the latest DOLFIN from the hg repository:
hg clone http://www.fenics.org/hg/dolfin
Then, navigate into the newly created directory
cd dolfin
and type in the following to build DOLFIN:
scons enableResolveCompiler=0
Note that we need to turn off the resolve compiler feature because of some strange bug in this function on Windows.
Finally, install DOLFIN by typing
scons install prefix=<prefix>
Replace <prefix> with some suitable directory, like C:\local.
To build the demos, simply type
scons enableDemos=1
Now run
dolfin.bat
to update the PATH, PYTHONPATH, and PKG_CONFIG_PATH environment variables temporary. You should then be able to try out the demos in the demo subfolder.

