Score:0

GCC fatal error: mpi.h: No such file or directory

za flag

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?

N0rbert avatar
zw flag
Please add details to your question: what is `ASD.c`, do you have any guides about its compilation? What is your Ubuntu version?
waltinator avatar
it flag
Install some of the packages shown by `dpkg -S /usr/include/mpi.h`
Score:3
zw flag

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
Victor Eijkhout avatar
cn flag
OP's system may have the `mpi.h` header, but the compile line does not have the `-Iwhatever` include option with the MPI directories.
Score:1
cn flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.