mpicc(1)

πŸ“¦ version 5.0.1, in ubuntu stonking

πŸ’– mpicc β€” like, the C compiler glow-up (manual page mpicc(1), from the MPI crew) πŸ’–


✨ NAME ✨

mpicc β€” compiles and links MPI programs written in C 🫢


🌸 DESCRIPTION 🌸

Okay bestie, listen. This command? It compiles and links MPI programs written in C. It hands you all the options and every special library you need to get your MPI code to actually build. No cap.

It is so important that you use this command, especially when you're linking programs, because it's the one bringing the necessary libraries to the function. Showing up empty-handed is not the vibe. πŸ’…


πŸŽ€ COMMAND LINE ARGUMENTS πŸŽ€

  • -show β€” shows you the commands that would be used, without actually running them. Peek behind the curtain, no commitment. πŸ‘€
  • -help β€” gives short help. A lil snack of information.
  • -cc=name β€” use compiler name instead of the default choice. Only do this if the compiler is compatible with the MPICH library (see below, bestie, it matters). πŸ™ˆ
  • -config=name β€” load a configuration file for a particular compiler. This is the slay: it lets a single mpicc command be used with multiple compilers.
  • -compile_info β€” shows the steps for compiling a program. Use this to see exactly what options and include paths mpicc is using.
  • -link_info β€” shows the steps for linking a program. Use this to see what options and libraries mpicc is using.
  • -profile=name β€” use the MPI profiling given by name. Details are down below. ⬇️
  • -echo β€” shows exactly what this program is doing. Heads up: this option should normally not be used. 🚫
  • -static_mpi β€” use a statically compile MPI library, but shared libraries for all of the other dependencies.
  • -mpi_abi β€” compile and link using the standard MPI ABI.
  • others β€” anything else gets passed to the compiler or linker. For example, -c causes files to be compiled, -g selects compilation with debugging on most systems, and -o name causes linking with the output executable given the name name.

πŸ¦‹ ENVIRONMENT VARIABLES πŸ¦‹

The environment variable MPICH_CC may be used to select a different C compiler and linker. But bestie, real talk: since MPICH is built with a particular C and Fortran compiler, changing the compilers used can cause problems. Only use this if you could intermix code compiled with the different compilers. 😬

The environment variable MPICC_PROFILE specifies a profile library and has the same effect as if -profile=$MPICC_PROFILE were used as an argument to mpicc. See the discussion of -profile below for more details. πŸ’œ


🌈 COMPATIBLE COMPILERS 🌈

The MPI library may be used with any compiler that uses the same lengths for basic data objects (such as long double) and that uses compatible run-time libraries. On many systems, the various compilers are compatible and may be used interchangeably β€” iconic, honestly.

But there are exceptions. If you use the MPICH_CC environment variable or the -cc=name command-line argument to override the choice of compiler and encounter problems, try reconfiguring MPICH with the new compiler and installing MPICH in a separate location. See the installation manual for more details. πŸ“–


⭐ EXAMPLES ⭐

To compile a single file foo.c, use:

mpicc -c foo.c

To link the output and make an executable, use:

mpicc -o foo foo.o

Combining compilation and linking in a single command:

mpicc -o foo foo.c

…is a convenient way to build simple programs. One command, whole build, main character energy. πŸ‘‘


πŸ’… SELECTING A PROFILING LIBRARY πŸ’…

The -profile=name argument allows you to specify an MPI profiling library to be used. name can have two forms:

  1. A library in the same directory as the MPI library
  2. The name of a profile configuration file

If name is a library, then this library is included before the MPI library. This allows the simple use of libraries that make use of the MPI profiling interface and that are installed in the same directory as the MPI library. πŸ“

If name.conf is the name of a file in the sysconfdir directory, then this is read and may define the following variables:

  • PROFILE_PRELIB β€” libraries (and paths) to include before the MPI library
  • PROFILE_POSTLIB β€” libraries to include after the MPI library
  • PROFILE_INCPATHS β€” C preprocessor arguments for any include files

For example, to add /usr/local/myprof/include to the include path and the library libmyprof.a in /usr/local/myprof/lib to the link step, you could create the file myprof.conf with the lines:

PROFILE_PRELIB="-L/usr/local/myprof/lib -lmyprof"
PROFILE_INCPATHS="-I/usr/local/myprof/include"

…and place it in the sysconfdir directory (this directory is set at configure time when MPICH is built). Then using the command-line argument -profile=myprof will cause these definitions to be added to the relevant compile commands. Lowkey magic. ✨


πŸ‘‘ SEE ALSO πŸ‘‘

mpicxx, mpifort, mpiexec


So yeah, that's the whole page, bestie. Quick sign-off: this is mpicc(1) from the MPI manual, dated 4/10/2026 β€” go forth and link things correctly, the MPI way, fr fr. πŸ§šπŸ’–

πŸ“¦ where this page comes from