9.1. Quick start: Building MPI applications
Although this section skips many details, it offers examples that will probably work in many environments.
Note that this section is a “Quick start” — it does not attempt to be comprehensive or describe how to build Open MPI in all supported environments. The examples below may therefore not work exactly as shown in your environment.
Please consult the other sections in this chapter for more details, if necessary.
Open MPI provides “wrapper” compilers that should be used for compiling MPI and OpenSHMEM applications:
The legacy names
mpif90 still exist,
and are simply symbolic links to the
compiler. Users are strongly encouraged to update all
build scripts to use
mpifort instead of
The intent is that users can simply invoke the Open MPI wrapper
compiler instead of their usual language compiler. For example,
instead of invoking your usual C compiler to build your MPI C
shell$ mpicc hello_world_mpi.c -o hello_world_mpi -g
For OpenSHMEM applications:
shell$ oshcc hello_shmem.c -o hello_shmem -g
All the wrapper compilers do is add a variety of compiler and linker flags to the command line and then invoke a back-end compiler. To be specific: the wrapper compilers do not parse source code at all; they are solely command-line manipulators, and have nothing to do with the actual compilation or linking of programs. The end result is an MPI executable that is properly linked to all the relevant libraries.
It is absolutely not sufficient to simply add
to your link line and assume that you will obtain a valid
Open MPI executable.