# Windows

### Compiling using Cygwin

Installing GROMACS on an existing installation of Cygwin is straightforward, and a procedure is described here. With the release of Gromacs 4.5.1, building on Windows without Cygwin has become considerably easier (see below), although still not as simple as using Cygwin. There are also some old binary packages here for Windows.

Try to avoid needing to remember that you're on a Windows machine. Life will be much better if you do all your GROMACS work using the Cygwin shells (e.g. for setting environment variables) and with Cygwin editors (emacs, vi), unless you enjoy "line-ending pain" and know how to use dos2unix/unix2dos. These skills are all necessary whenever you are using GROMACS in real-world high-performance computing non-Windows environments and you should be planning your life so that your primary computing platform is not running Windows. Thus, learning workflows that are transferable is a good thing.

### Compiling without Cygwin

The following outline is done from memory and should work on Windows XP or later.  I haven't yet tried a "fresh" following of these instructions, as I don't want to make any changes to my stable build environment.  When I get the chance, I'll work throught this tutorial on a fresh Windows install and fill in the gaps.

1. Install Microsoft Visual Studio (2008 or later should work, express versions may also work)
2. Install ICC+MKL if desired (ICC+MKL may provide up to a 15% speed improvement).
3. Install NASM.
4. Install CMake (2.8 and 2.9 have been tested on my machine)

#### Compiling GROMACS:

2. Run CMake
3. Specify the source code directory in box "Where is the source code"
4. Specify a different location to put the built GROMACS in the box "Where to build the binaries"
5. Configure. (Yes, to create directories.  When asked about a generator, find the one that matches your desired compiler setup, e.g. Visual Studio 2008)
6. At this point, CMake may stop because it cannot find FFTW.  If you have an FFTW installation, tell GROMACS where it is and which libraries using the options: FFTW3F_INCLUDE_DIR and FFTW3F_LIBRARIES

If you don't want to use FFTW3F, you can also set GMX_FFTW_LIBRARY to several other options.  fftpack should work on all systems (without installing additional software); however, fftpack can give significantly reduced performance on FFT operations (such as PME).  If you have Intel MKL, you can also choose that option.

7. I'm choosing GMX_FFTW_LIBRARY=mkl for this tutorial.  Click configure, and CMake will stop and ask for help finding MKL.  The right values depend on your MKL version and installation details, but on my machine the location of MKL_INCLUDE_DIR=C:\Program Files (x86)\Intel\MKL\10.2.4.032\include\

QUESTION FOR DEVS: The help flag on MKL_LIBRARIES actually says "Path to library", but I don't think that's what this option is looking for (when I give a path here, CMake gives about 500 warnings).

MKL_LIBRARIES is a bit tricky, as which MKL has a lot of choices here.  In particular, MKL allows you to choose the threading model and the integer model.  For my purposes, I use

for 32 bit:
MKL_LIBRARIES=mkl_intel_c.lib mkl_core.lib mkl_sequential.lib libguide.lib

for 64 bit:
MKL_LIBRARIES=mkl_solver_lp64_sequential.lib mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib
8. Hit configure again, and again if necessary.  Finally hit generate.
9. Go to Visual Studio.  If you want to use ICC, you should select all the executables and libraries, right click, and click build with ICC.
10. If you want to use MKL: Select all executables, right click, properties.  Go to linker, Additional Library Directories.  Once again, the actual paths depend on your MKL installation, but for mine:

For 32 bit:
C:\Program Files (x86)\Intel\MKL\10.2.4.032\ia32\lib
For 64 bit:
C:\Program Files (x86)\Intel\MKL\10.2.4.032\em64t\lib
11. Compile and take a 10 minute break.