title: How to successfully compile mpi4py using MS HPC Server 2008 R2's MPI stack?
body: <p>So the story goes: I need a MPI wrapper for Python. </p>
  
  <p>I know there's <a href="http://code.google.com/p/mpi4py/" rel="noreferrer">mpi4py</a>. For the current work I (mostly) use Python and Windows, I'd like to use the Microsoft HPC Cluster Pack, having access to a few pretty "strong" machines running Win 2008 Server. Just to mention, besides Win-experience, I do have a bit of *nix experience with MPI and stuff, but that's pretty moot point for this problem.</p>
  
  <p>My interest in mpi4py was renewed when I ran into <a href="http://pytools.codeplex.com/" rel="noreferrer">Python Tools for Visual Studio</a>. That's some seriously great stuff. Anyone that's a fan of Visual Studio and Python should try it. Good work, and a great debugger.</p>
  
  <p>The doc pages of PTVS state the installation of mpi4py is easy... and for ActiveState Python it seems to be true. However, if you don't use ActiveState's Python and instead use the "normal" Python distribution from python.org, you seem to be a bit out of luck. </p>
  
  <p>My development machine is a laptop w/ Win7 64bit and Python 2.6, both in 64-bit and 32-bit flavors.
  I have installed the MS HPC Pack 2008 R2 MS MPI and SDK. I have Visual Studio 2008 and 2010, everything dutifully patched. </p>
  
  <p>There's no binary installer and knowing how Unix MPIs can be exceedingly picky wrt to the MPI version they're linked with, I wanted to build my own mpi4py. mpi4py basically relies on having a MPI .dll (.pyd actually) that binds the python calls to MPI libs.</p>
  
  <p>easy_installing of mpi4py and building of that library has failed - not being able to point to the MPI libs. OK, no problem, I downloaded the mpi4py tarball, extracted it and altered the <strong>mpi.cfg</strong> file so that it points to the correct folders:</p>
  
  <pre><code># Microsoft MPI example
  # ---------------------
  [msmpi]
  define_macros = MS_MPI=1
  mpi_dir = $CCP_HOME
  include_dirs = %(mpi_dir)s\Inc
  libraries = msmpi
  library_dirs = %(mpi_dir)s\lib\i386
  </code></pre>
  
  <p>The MS MPI installer registers an environment variable CCP_HOME pointing to the exact install location of the Pack. The name "CCP" must be leftover from the days it was called Microsoft Compute Cluster Pack). Got to pass this to the original mpi4py developer.</p>
  
  <p>After this, the compilation passes fine, but I can't link - there are three unresolved externals:</p>
  
  <pre><code>MPI.obj : error LNK2019: unresolved external symbol _MPI_Type_create_f90_integer@8 referenced in ...
  MPI.obj : error LNK2019: unresolved external symbol _MPI_Type_create_f90_real@12 ...
  MPI.obj : error LNK2019: unresolved external symbol _MPI_Type_create_f90_complex@12 ...
  </code></pre>
  
  <p>Seems that the MS MPI msmpi.lib from HPC 2008 R2 does not implement these, so I can't build the MPI.pyd.</p>
  
  <p>I could try to comment out these in the mpi4py C source file, but I don't think this is the right path.</p>
  
  <p>Thanks in advance!</p>