HP-MPI Version 2.0 for Windows Release Note
10 C Command-Line Basics
The utility "%MPI_ROOT%\bin\mpicc" is included to aid in command line compilation. To
compile with this utility, set MPI_CC to the path of the command line compiler you want to use.
Specify -mpi32 or -mpi64 to indicate if you are compiling a 32- or 64-bit application. Specify
the command line options that you normally pass to the compiler on the mpicc command line.
The mpicc utility adds additional command line options for HP-MPI include directories and
libraries. The -show option can be specified to mpicc to display the command generated without
executing the compilation command. See the manpage mpicc(1) for more information.
To construct the desired compilation command, the mpicc utility needs to know what command
line compiler is to be used, the bitness of the executable that compiler will produce, and the
syntax accepted by the compiler. These can be controlled by environment variables or from the
command line.
Table 10-1 mpicc Utility
Command LineValueEnvironment Variable
-mpicc <value>desired compiler (default cl)MPI_CC
-mpi32 or -mpi6432 or 64 (no default)MPI_BITNESS
-mpisyntax <value>windows or unix (default windows)MPI_WRAPPER_SYNTAX
For example, to compile hello_world.c using a 64-bit 'cl' contained in your PATH could be
done with the following command since 'cl' and the 'Windows' syntax are defaults:
C:\> "%MPI_ROOT%\bin\mpicc" -mpi64 hello_world.c /link /out:hello_world_cl64.exe
Or, use the following example to compile using the PGI compiler which uses a more UNIX-like
syntax:
C:\> "%MPI_ROOT%\bin\mpicc" -mpicc pgcc -mpisyntax unix -mpi32 hello_world.c -o hello_world_pgi32.exe
To compile C code and link against HP-MPI without utilizing the mpicc tool, start a command
prompt that has the appropriate environment settings loaded for your compiler, and use it with
the compiler option:
C:\> /I"%MPI_ROOT%\include\<32|64>"
and the linker options:
C:\> /libpath:"%MPI_ROOT%\lib" /subsystem:console <libhpmpi64.lib|libhpmpi32.lib>
The above assumes the environment variable MPI_ROOT is set.
For example, to compile hello_world.c from the Help directory using Visual Studio (from a
Visual Studio 2008 command prompt window):
cl hello_world.c /I"%MPI_ROOT%\include\64" /link /out:hello_world.exe /libpath:"%MPI_ROOT%\lib" /subsystem:console
libhpmpi64.lib
The PGI compiler uses a more UNIX-like syntax. From a PGI command prompt:
pgcc hello_world.c -I"%MPI_ROOT%\include\64" -o hello_world.exe -L"%MPI_ROOT%\lib" -lhpmpi64
10.1 mpicc.bat
The mpicc.bat script links by default using the static run-time libraries /MT. This behavior
allows the application to be copied without any side effects or additional link steps to embed
the manifest library.
When linking with /MD (dynamic libraries), you must copy the generated
<filename>.exe.manifest along with the .exe/.dll file or the following run-time error
will display:
This application has failed to start because MSVCR90.dll was not found.
Re-installing the application may fix this problem.
10.1 mpicc.bat 45