Search code examples
c++macos-mojave

C++ compiling with MacOS Mojave : fatal error: mpi.h: No such file or directory


My question closely follows the problem reported here: Code::Blocks C++ compiling with MacOS Mojave : fatal error: sys/cdefs.h: No such file or directory (although I am not using CodeBlocks).

I had exactly the same problem and reinstalled gcc and xcode, which fixed the initial error. However, I now have a similar error message with fatal error: mpi.h: No such file or directory

I have tried reinstalling hdf5 and open-mpi similarly and neither have worked. Can anyone help?

Many thanks


Solution

  • OpenMPI comes with a set of wrappers for the compilers:

    mpicc
    mpicxx
    

    These will set up all the include paths and libraries to include for the C or the C++ versions of MPI.

    If you need to change the underlying compiler (so not use the one by default), you can set:

    OMPI_CC
    OMPI_CXX
    

    in the same way as you would set CC and CXX.