title: Enabling OpenMPI on Linux
body: <p>I'm trying to enable OpenMPI on Ubuntu using CodeBlocks. I have already downloaded it using:</p>
  
  <blockquote>
    <p>sudo apt-get install -y  autotools-dev g++ build-essential
    openmpi1.6-bin openmpi1.6-doc libopenmpi1.6-dev</p>
  </blockquote>
  
  <p>Afterwards I tried to run the following code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;mpi.h&gt;
  
  int main(int argc, char **argv)
  {
     int size, rank;
     MPI_Init(&amp;argc, &amp;argv);
     MPI_Comm_size(MPI_COMM_WORLD, &amp;size);
     MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank);
     printf("SIZE = %d RANK = %d\n",size,rank);
     MPI_Finalize();   
     return(0);
  }
  </code></pre>
  
  <p>But I got this error:</p>
  
  <blockquote>
    <p>fatal error: mpi.h: No such file or directory</p>
  </blockquote>
  
  <p>Then I changed the c++ compiler from <code>g++</code> to <code>mpicxx</code> as it's recommended here: <a href="http://www.open-mpi.de/faq/?category=mpi-apps#general-build" rel="nofollow">FAQ: Compiling MPI</a>.<br>
  But when I try to run my code now,  I get the following bunch of errors:</p>
  
  <pre><code>openmpi.cpp|| undefined reference to `MPI_Init'|
  openmpi.cpp|| undefined reference to `ompi_mpi_comm_world'|
  openmpi.cpp|| undefined reference to `MPI_Comm_size'|
  openmpi.cpp|| undefined reference to `ompi_mpi_comm_world'|
  openmpi.cpp|| undefined reference to `MPI_Comm_rank'|
  openmpi.cpp|| undefined reference to `MPI_Finalize'|
  [...]
  </code></pre>
  
  <p>I assume, I have to add the Path or link the library, but I'm not sure how to achieve this.  I also don't know where OpenMPI has been installed on my machine.<br>
  I have downloaded the folder from the website, as well, if that can help.</p>
  
  <p><strong>Update</strong><br>
  After adding <code>mpicxx</code> to the linker and <code>-pthread -L/opt/openmpi/lib -lmpi_cxx -lmpi -ldl -lm -Wl,--export-dynamic -lrt -lnsl -lutil -lm -ldl</code> as additional flags, I finally can compile the code.<br>
  But now I get another error:</p>
  
  <pre><code>[[INVALID],INVALID] ORTE_ERROR_LOG: A system-required executable either could not be found or was not executable by this user in file ess_singleton_module_c at line 231
  [...]
  Soory! You were supposed to get help about:  
  orte_init:startup:internal-failure  
  But I couldn't open the file:  
  /usr/share/openmpi/help-orte-runtime: No such file or directory.
  </code></pre>