LAM/MPI logo

LAM/MPI General User's Mailing List Archives

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

From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2003-10-08 12:57:36


As a final note on this -- this question comes up so often that I finally
added an FAQ item about it under "Running LAM/MPI applications", the
questions "My Fortran MPI program fails to link! Why?" and "My C++ MPI
program fails to link! Why?"

On Thu, 2 Oct 2003, Brian Barrett wrote:

> On Oct 1, 2003, at 10:02 AM, Olivier Paradis-Beland wrote:
>
> > So, I enter the following command : [ ]$ mpif77 pi.f
> > and lam gives me that error message :
> >
> > FORTRAN 77 Compiler 7.5a, Copyright (c) 1987-2002, Absoft Corp.
> > pi.o: In function `main':
> > pi.o(.text+0x59): undefined reference to `MPI_INIT'
> > pi.o(.text+0x8a): undefined reference to `MPI_COMM_RANK'
> > pi.o(.text+0xb6): undefined reference to `MPI_COMM_SIZE'
> > pi.o(.text+0x325): undefined reference to `MPI_BCAST'
> > pi.o(.text+0x4b9): undefined reference to `MPI_REDUCE'
> > pi.o(.text+0x5ba): undefined reference to `MPI_FINALIZE'
> > collect2: ld returned 1 exit status
>
> This looks like a problem with linking in the Fortran library - the
> linker is not able to find the expected symbols. All of the symbols
> listed above are valid MPI symbols, so they really should be there. I
> would suspect that LAM and the Fortran compiler are using different
> name mangling schemes, resulting in LAM proving a symbol link
> __mpi_init and Absoft mangled the symbol to MPI_INIT.
>
> Did you compile LAM to use the Absoft Fortran compiler? As you used
> mpif77 to compile your code, I'm assuming so. However, it is possible
> to override which compiler LAM uses with the LAMF77 environment
> variable. Mixing Fortran compilers is generally a bad idea - if LAM is
> built with gcc (for example), then LAM applications should really be
> built with gcc and not Absoft's compiler.
>
> One other possible problem is Absoft-specific. The default mode of
> Absoft's compiler is to be case-sensitive (so MPI_INIT and MPI_Init are
> different symbols). Most Fortran compilers are not, so Absoft provides
> a flag to be case insensitive. In doing so, the compiler changes its
> name mangling scheme. I think the version of LAM you are using was
> compiled with the special case-insensitive flag but your user
> application was not. Hence, the missing symbols. I would check with
> whomever compiled your installation of LAM - you need to use the same
> flags to mpif77 that they provided for compiling the Fortran interface.
>
>
> Hope this helps,
>
> Brian
>
>

-- 
{+} Jeff Squyres
{+} jsquyres_at_[hidden]
{+} http://www.lam-mpi.org/