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

前端 未结 7 1308
迷失自我
迷失自我 2020-12-08 00:50

when I compile my script with only

#include 

it tells me that there is no such file or directory. But when i include the path

相关标签:
7条回答
  • 2020-12-08 01:06

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

    sudo apt install libopenmpi-dev
    pip install mpi4py
    

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

    Succeded.

    0 讨论(0)
  • 2020-12-08 01:07

    As suggested above the inclusion of

    /usr/lib/openmpi/include 
    

    in the include path takes care of this (in my case)

    0 讨论(0)
  • 2020-12-08 01:12

    On my system Ubuntu 16.04. I installed :

    sudo apt install libopenmpi-dev
    

    after I used mpiCC to compile and it works

    0 讨论(0)
  • 2020-12-08 01:16

    Debian appears to include the following:

    • mpiCC.openmpi
    • mpic++.openmpi
    • mpicc.openmpi
    • mpicxx.openmpi
    • mpif77.openmpi
    • mpif90.openmpi

    I'll test symlinks of each for mpic, etc., and see if that helps the likes of HDF5-openmpi enabled find mpi.h.

    Take that back Debian includes symlinks via their alternatives system and it still cannot find the proper paths between HDF5 openmpi packages and mpi.h referenced in the H5public.h header.

    0 讨论(0)
  • 2020-12-08 01:20

    You can execute:

    $ mpicc -showme 
    

    result :

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

    This command shows you the necessary libraries to compile mpicc

    Example:

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

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

    $ ./example
    
    0 讨论(0)
  • 2020-12-08 01:30

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

    • C - mpicc
    • C++ - mpiCC, mpicxx, mpic++
    • FORTRAN - mpifort, mpif77, mpif90

    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.

    0 讨论(0)
提交回复
热议问题