Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MPI LINK ERROR - HELP!

0 views
Skip to first unread message

Cristian GATU

unread,
Feb 7, 2001, 9:52:39 AM2/7/01
to
Hi!

Using MPI (LAM 6.3) with a f90 compiler for the program:
PROGRAM mytest
INCLUDE 'mpif.h'

INTEGER ierr

CALL MPI_INIT(ierr)
CALL MPI_FINALIZE(ierr)

STOP
END
I get the following error:

outremer(58)/home/cgatu> f90 -L/freesoft/lib -lmpi++ -lmpi -ltstdio
-ltrillium -largs -lt -lsocket -lnsl -lgen testMPI.f
Undefined first referenced
symbol in file
mpi_finalize_ testMPI.o
mpi_init_ testMPI.o
ld: fatal: Symbol referencing errors. No output written to a.out

I will appreciate any suggestion and help. Thank you very much,
Cristian Gatu
--
Institut d'Informatique Tel: +41 (0) 32 718 27 27
Universite de Neuchatel Fax: +41 (0) 32 718 27 01
Rue Emile-Argand 11 E-mail: cristi...@info.unine.ch
CH-2007 Neuchatel URL: http//iiun.unine.ch/people/cgatu
Switzerland

Richard Maine

unread,
Feb 7, 2001, 12:34:18 PM2/7/01
to
Cristian GATU <cristi...@unine.ch> writes:

> Using MPI (LAM 6.3) with a f90 compiler for the program:..

You haven't specified the compiler, which might matter.

> outremer(58)/home/cgatu> f90 -L/freesoft/lib -lmpi++ -lmpi -ltstdio
> -ltrillium -largs -lt -lsocket -lnsl -lgen testMPI.f
> Undefined first referenced
> symbol in file
> mpi_finalize_ testMPI.o
> mpi_init_ testMPI.o

Looks likely to be typical C/Fortran interface isues. Does the MPI
library you are using document itself as being for C or Fortran?
(And if for Fortran, are you linking to the Fortran version of the
library....

Umm... Interrupt...Recycle brain. I just noticed something more
likely. If the suggestion below doesn't help, then we can think
further along the path started above.

The unix linkers are annoyingly stupid, at least by the standards
that I was used to in prior days. One of the many "features" of
pretty much all unix linkers is that they process command-line
arguments one at a time in a way that makes things very dependent
on the order of things on the command line. You need to put the
testMPI.f file *BEFORE* the libraries it references. (Likewise,
you sometimes have to worry about putting libraries in the right
order if one library references another).

With your command line, the linker first comes to the mpi++ and mpi
libraries. It doesn't yet see anything that needs these libraries
so they are essentially ignored. Later, it comes to your code;
now there is a reference to the mpi stuff. But by now the linker
has "forgotten" that you were linking to the mpi libraries, so it
doesn't look in them. (I'm sure there are those who will explain
how logical and good this all is, and that it really is a feature
instead of a "feature" - I'll stick with my opinion). Regardless
of whether or not one considers it a "feature", the solution is to
re-order your command line. Put the .f file before all the libraries.

--
Richard Maine | Good judgement comes from experience;
ma...@altair.dfrc.nasa.gov | experience comes from bad judgement.
| -- Mark Twain

Holger Bauer

unread,
Feb 8, 2001, 11:10:11 AM2/8/01
to
Please check, if your bug is related to inconsistent compiler flags:
To avoid such problems I suggest to always use the mpif90/mipCC/mpicc
scripts which should be on your system. If you compile your code
with different compiler flags as your MPI library this might end
up in undefined symbols. For example the Absoft compiler has very
unusual default settings (f90 is case sensitive). With this you would
have to use exactly the same name for the MPI routines as they are
defined in the library.
If you use mpif90 you even don't have to specify the -lmpi libraries
nor you have to set your include path for the mpif.h file.

Regards,

Holger



> outremer(58)/home/cgatu> f90 -L/freesoft/lib -lmpi++ -lmpi
> -ltstdio -ltrillium -largs -lt -lsocket -lnsl -lgen testMPI.f
> Undefined first referenced symbol in file mpi_finalize_
> testMPI.o mpi_init_ testMPI.o ld: fatal: Symbol referencing
> errors. No output written to a.out

> I will appreciate any suggestion and help. Thank you very much,
> Cristian Gatu -- Institut d'Informatique Tel: +41 (0) 32 718 27
> 27 Universite de Neuchatel Fax: +41 (0) 32 718 27 01 Rue
> Emile-Argand 11 E-mail: cristi...@info.unine.ch CH-2007
> Neuchatel URL: http//iiun.unine.ch/people/cgatu Switzerland

--
Holger...@lampoldshausen.de

0 new messages