title: Compile C++ MPI Code on Windows
body: <p>I have just installed <a href="https://msdn.microsoft.com/en-us/library/bb524831(v=vs.85).aspx" rel="nofollow">Microsoft MPI</a> (MS-MPI) which "is a Microsoft implementation of the Message Passing Interface standard for developing and running parallel applications on the Windows platform".</p>
  
  <p>The site also contains a link to a featured tutorial:
  <a href="https://blogs.technet.microsoft.com/windowshpc/2015/02/02/how-to-compile-and-run-a-simple-ms-mpi-program/" rel="nofollow">How to compile and run a simple MS-MPI program</a>.</p>
  
  <p>The compilation there is done using Visual Studio.</p>
  
  <p>How to compile a C++ MPI code at the command line (without using VS)?</p>
  
  <hr>
  
  <p>A simple program to be compiled:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;mpi.h&gt;
  
  int main(int argc, char *argv[]) { 
  MPI::Init(argc, argv);
  
       int num_procs = MPI::COMM_WORLD.Get_size();
       int rank = MPI::COMM_WORLD.Get_rank();
       std::cout &lt;&lt; "Hello world from processes " &lt;&lt; rank
                  &lt;&lt; " of " &lt;&lt; num_procs &lt;&lt; "\n";
  MPI::Finalize();
  
  return 0;
  }
  </code></pre>