[mpich-discuss] Trouble linking mpich2 libraries

Dave Goodell goodell at mcs.anl.gov
Tue Oct 18 14:21:19 CDT 2011

Are you actually "#include"ing mpi.h?

Are you certain that you aren't inadvertently picking up a different implementation's mpi.h that does not properly support MPI's C++ bindings?  You might be able to check this by running your failing compile line with the "-M" option added to cause the compiler to output a make dependency rule for all of the header files that were included.

An aside: your problem is compile-time, not link-time, but your "CLIBS" variable has a set of suspicious flags in it.  If you are linking with mpicxx then you should not add "-lmpich" or "-lmpichcxx" to your link line.  Doing so will very likely cause you problems later on.


On Oct 18, 2011, at 6:15 AM CDT, Daniel Fulton wrote:

> Hi,
> I've just compiled and installed mpich2-1.4.1p1 on my workstation, but I'm having trouble linking it to my application.   I'm running on an Intel Core i3, using openSUSE 11.4.  The version in the repositories is old, hence the install from source.
> When I try to make my program, I get errors:
> In file included from ../TOOPAC/src/ArrayFunctions.cpp:9:0:
> ../TOOPAC/src/MPIInclude.h:6:11: error: ‘MPI’ does not name a type
> In file included from ../TOOPAC/src/Converter.cpp:11:0:
> ../TOOPAC/src/MPIInclude.h:6:11: error: ‘MPI’ does not name a type
> In file included from ../TOOPAC/src/ArrayFunctions.cpp:18:0:
> ../TOOPAC/src/MPIFunctions.h:16:19: error: ‘MPI’ does not name a type
> ../TOOPAC/src/MPIFunctions.h:19:1: error: expected unqualified-id before ‘int’
> ../TOOPAC/src/MPIFunctions.h:34:12: error: ‘MPI’ does not name a type
> ...
> and many many similar.  The program has been compiled successfully before, so I know it is just a problem with my mpich2 install.
> Compile options are as follows:
> COMPILE  = mpicxx -c -O -DUSE_FORTRAN_DOUBLE -DUSE_HDF5 -DH5_USE_16_API -DUSE_MPI -DUSE_PETSC -I. -I../TOOPAC/src -I../TOOPAC/tests -I../utils/src -I/usr/include -I/usr/local/include -I/usr/local/petsc-3.1-p8/include -I/usr/local/petsc-3.1-p8/linux-gnu-c-debug/include
> FCOMPILE = mpif90 -c -O -w
> LINKER   = mpicxx
> LIBTOOL  = ar r
> CLIBS    = ../utils/lib/lib.a -lhdf5 -L/usr/local/lib -lmpich -lmpichcxx -L/usr/local/petsc-3.1-p8/linux-gnu-c-debug/lib -lpetsc -lflapack -lfblas -lgfortran -ldl
> And I believe all the header files are in the appropriate place in /usr/local include:
> dfulton at stoat:~> ls /usr/local/include/
> mpi_base.mod       mpif.h   mpiof.h          mpix.h            opa_queue.h
> mpi_constants.mod  mpi.h    mpio.h           opa_config.h      opa_util.h
> mpicxx.h           mpi.mod  mpi_sizeofs.mod  opa_primitives.h  primitives
> Any thoughts on where I'm going wrong?
> Dan
> _______________________________________________
> mpich-discuss mailing list     mpich-discuss at mcs.anl.gov
> To manage subscription options or unsubscribe:
> https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss

More information about the mpich-discuss mailing list