Monday, February 23, 2009

Complie an MPICH2 Application (C++)

Developer Visual Studio 6.0

Visual C++ 6.0 cannot handle multiple functions with the same type signature
that only differ in their return type. So you must define HAVE_NO_VARIABLE_RETURN _TYPE_SUPPORT in your project.
1. Create a project and add your source files.
2. Bring up the settings for the project by hitting Alt F7. Select the Preprocessor
Category from the C/C++ tab. Enter “HAVE_NO_VARIABLE_RETURN_TYPE_SUPPORT”
into the Preprocessor box. Enter “C:\Program Files\MPICH2\include” into the “Additional include directories” box.
3. Select the Input Category from the Link tab. Add cxx.lib and
mpi.lib to the Object/library modules box. Add C:\Program Files\MPICH2\lib
to the “Additional library path” box.
4. Compile your application.
[Source: mpich2-doc-windev.pdf, section 9.10.2]

Developer Studio .NET 2003

For Developer Studio .NET 2003 or newer you can use the example projects provided with the release as a guide to creating your own projects.
1. Create a project and add your source files.
2. Bring up the properties dialog for your project by right clicking the project name and selecting Properties.
3. Navigate to Configuration Properties::C/C++::General
4. Add C:\Program Files\MPICH2\include to the “Additional Include Directories” box.
5. Navigate to Configuration Properties::Linker::General
6. Add C:\Program Files\MPICH2\lib to the “Aditional Library Directories” box.
7. Navigate to Configuration Properties::Linker::Input
8. Add cxx.lib and mpi.lib and fmpich2.lib to the “Additional Dependencies” box.
If your application is a C application then it only needs mpi.lib. If it is a C++ application then it needs both cxx.lib and mpi.lib. If it is a Fortran application then it only needs one of the fmpich2[s,g].lib libraries. The fortran library comes in three flavors fmpich2.lib, fmpich2s.lib and fmpich2s.lib. fmpich2.lib contains all uppercase symbols and uses the C calling convention like this: MPI INIT. fmpich2s.lib contains all uppercase symbols and uses the 9 RUNTIME ENVIRONMENT 30 stdcall calling convention like this: MPI INIT@4. fmpich2g.lib contains all lowercase symbols with double underscores and the C calling convention like this: mpi init . Add the library that matches your Fortran compiler.
9. Compile your application.
[Source: mpich2-doc-windev.pdf, section 9.10.2]

1. Trouble Shooting

C++ and SEEK_SET
Some users may get error messages such as
SEEK_SET is #defined but must not be for the C++ binding of MPI

The problem is that both stdio.h and the MPI C++ interface use SEEK_SET, SEEK_CUR, and SEEK_END. This is really a bug in the MPI-2 standard. You can try adding
#undef SEEK_SET
#undef SEEK_END
#undef SEEK_CUR

before mpi.h is included, or add the definition
-DMPICH_IGNORE_CXX_SEEK

to the command line (this will cause the MPI versions of SEEK_SET etc. to be skipped).
[Source: http://www.mcs.anl.gov/research/projects/mpich2/support/index.php?s=faqs#cxxseek]

1 comment: