LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Brian Barrett (brbarret_at_[hidden])
Date: 2006-03-31 10:50:05


On Mar 31, 2006, at 10:36 AM, Guiyuan Lei wrote:

> I have one program which was written in c++, it also uses public
> software package including lapack, blas and blitz++. I have
> compiled the code and run the program successfully by mpich. The
> compiling command is as following:
>
> g++ -c gibbsreg.cpp -I/usr/lib/mpich/include
> mpif77 -lstdc++ gibbsreg.o -lblas -llapack -lg2c -lm
>
> But when I tried to compile this code by using lam/mpi (on another
> machine, which has both lam/mpi and mpich installed), it failed.
> g++ -c gibbsreg.cpp -I/usr/lib/lam/include
>
> mpif77 -lstdc++ gibbsreg.o -lblas -llapack -lg2c -lm
>
> The compling comes with the following error. Anybody has any idea
> about this lam/mpi problem? Why it successed with mpich, but failed
> with lam/mpi? I guess it is because the mixture using of Fortran
> and c++ in the code. Many thanks in advance.
>
> gibbsreg.o(.gnu.linkonce.r._ZTVN3MPI2OpE+0x10): undefined reference
> to `MPI::Op::Init(void (*)(void const*, void*, int, MPI::Datatype
> const&), bool)'
It looks like we don't include the library containing the C++
interface when linking with the Fortran compiler (which is only
slightly strange because we *do* include the Fortran interface
library when linking with the C++ compiler). Anyway, all the symbols
that the linker complained about are in the library that contains the
C++ interface, which is called liblammpi++. I think if you make your
link line:

   mpif77 -llammpi++ -lstdc++ gibbsreg.o -lblas -llapack -lg2c -lm

everything should work just fine. I can't see any reason not to add
the C++ interface library to the list of libraries with the mpif77
wrapper (which is probably what MPICH does), so I'll add that to our
to-do list.

Hope this helps,

Brian

-- 
   Brian Barrett
   LAM/MPI developer and all around nice guy
   Have a LAM/MPI day: http://www.lam-mpi.org/