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

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?

2

2 Answers

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
1

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.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like