c++ - fatal error: mpi.h: No such file or directory #include

c++ – fatal error: mpi.h: No such file or directory #include

c++ – fatal error: mpi.h: No such file or directory #include

The problem is almost certainly that youre not using the MPI compiler wrappers. Whenever youre compiling an MPI program, you should use the MPI wrappers:

n

    • n

    • C – mpicc

n

    • C++ – mpiCC, mpicxx, mpic++

n

    • FORTRAN – mpifort, mpif77, mpif90

n

n

These wrappers do all of the dirty work for you of making sure that all of the appropriate compiler flags, libraries, include directories, library directories, etc. are included when you compile your program.

On my system, I was just missing the Linux package.

n

sudo apt install libopenmpi-devnpip install mpi4pyn

n

(example of something that uses it that is a good instant test to see if it succeeded)

n

Succeded.

c++ – fatal error: mpi.h: No such file or directory #include

You can execute:

n

$ mpicc -showme n

n

result :

n

gcc -I/Users/<USER_NAME>/openmpi-2.0.1/include -L/Users/<USER_NAME>/openmpi-2.0.1/lib -lmpn

n

This command shows you the necessary libraries to compile mpicc

n

Example:

n

$ mpicc -g  -I/Users/<USER_NAME>/openmpi-2.0.1/include -o [nameExec] [objetcs.o...] [program.c] -lmnnn$ mpicc -g  -I/Users/<USER_NAME>/openmpi-2.0.1/include -o example file_object.o my_program.c otherlib.o -lmn

n

this command generates executable with your program in example, you can execute :

n

$ ./examplen

Related posts on c++  :

Leave a Reply

Your email address will not be published.