Setting up G++ or ICC for mpi.h on Ubuntu

Mikhail picture Mikhail · Apr 23, 2011 · Viewed 22.5k times · Source

I have never done any major programing outside of VS08.

I am trying to compile a program called LAMMPS with either of the two relevant make files. One calls g++ and the other calls icc (Intel's compiler).

icc produces this error:

icc -O -DLAMMPS_GZIP -DMPICH_SKIP_MPICXX -DFFT_FFTW -M write_restart.cpp > write_restart.d write_restart.cpp(15): catastrophic error: cannot open source file "mpi.h" #include "mpi.h"

and g++ throws this error

g++ -g -O -DLAMMPS_GZIP -DMPICH_SKIP_MPICXX -DFFT_FFTW -M verlet.cpp > verlet.d pointers.h:25: fatal error: mpi.h: No such file or directory compilation terminated.

The mpi.h file is located in /usr/lib/openmpi/include

It is my understanding that I need to set that $PATH variable which reads

bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/opt/intel/bin:/usr/lib/openmpi/include:

and $LD_LIBRARY_PATH which currently reads

/usr/lib/openmpi/lib:

SO, how does one include the mpi.h file? So that either icc or g++ find it?

Answer

Wirawan Purwanto picture Wirawan Purwanto · Apr 23, 2011

mpi.h is a header for MPI library. That would be included if you use mpic++ MPI compiler wrapper instead of g++ in your makefile. mpic++ will call the appropriate compiler. From what you describe you have openmpi package installed on your ubuntu machine.

For more info, you need to consult the manual, e.g.

http://lammps.sandia.gov/doc/Section_start.html#2_2 (for LAMMPS)

and perhaps you need to see openmpi manual as to how to set up additional compiler. Not sure if this can be done after openmpi itself has been built. By default I think in Ubuntu openmpi compiler wrappers would only call g++. CMIIW.