MPI Library File Link Error

Symptom

When the mpirun command is executed, the error message "error while loading shared libraries: libmpi.so.12: cannot open shared object file: No such file or directory" is displayed, as shown below.

Solution

Add the MPI library to the environment variable LD_LIBRARY_PATH. For example:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/mpich/lib