1

When I try to execute code by using this command:

gcc ASD.c -o ASD.out*

I get this:

ASD.c:2:10: fatal error: mpi.h: No such file or directory
    2 | #include <mpi.h>
      |          ^~~~~~~
compilation terminated.

Any help to fix this, please?

Pablo Bianchi
  • 15,657
Saeed Alhothali
  • 21
  • 1
  • 1
  • 2

2 Answers2

4

This error message means that your system misses header file named mpi.h.

Depending on your use-case you need to install the following packages:

sudo apt-get install build-essential linux-generic libmpich-dev libopenmpi-dev
N0rbert
  • 99,918
  • 2
    OP's system may have the mpi.h header, but the compile line does not have the -Iwhatever include option with the MPI directories. – Victor Eijkhout Feb 02 '22 at 17:49
2

For compiling MPI codes you should use mpicc as the compiler. This is a script* around gcc (or whatever compiler you have) that sets the proper include and library paths.

If mpicc is an unknown command on your system, see the other answer for the missing packages.

*with OpenMPI it's actually a small executable.