This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Linking F90 code to C library
Richard,
Thanks for the reply. I'm not sure you're interpreting the meaning of
"weak" correctly. I didn't know exactly what it means, either (I knew I
should have taken a course on compiler design!), so I just googled on it
and came across this explanation:
http://www.netlib.org/utk/papers/mpi-book/node190.html
>From this explanation, a weak symbol is in the library, but can be
replaced (with no complaints) by another symbol from a different library
if multiple libraries have the same symbol at link time.
I asked if the problem is with gfortran, because gfortran is the command
doing the linking. Look at the command in my original message - gfortran
is the command producing the error. In reality ld is probably doing all
the real work, and gfortran is just a front-end to it that does some
fortran-specific stuff.
Prentice
On Wed, 2005-04-06 at 13:31 -0700, Richard E Maine wrote:
> On Apr 6, 2005, at 1:10 PM, Bisbal, Prentice wrote:
>
> > initialize.o(.text+0xe): In function `initialize_':
> > : undefined reference to `mpi_init__'
> >
> > Looking at my mpich library with nm shows that mpi_init__ is present:
> >
> > nm /opt/lib/libmpich.a | grep mpi_init_
> > 00000000 W mpi_init__
> > 00000000 T pmpi_init__
>
> I'm not intimately familiar with all of the linking terms either, but
> reading the nm man page leads me to suspect that mpi_init__ is *NOT* in
> that library. If I'm reading correctly, that W means that it isn't
> mpi_init__ itself, but instead a reference of some kind to mpi_init__.
> I don't quite understand the "weak" business, but I think it is still a
> form of reference.
>
> > Is this a problem with gfortran, or my library?
>
> Hard to see how it could possibly be in gfortran. Gfortran would just
> make the reference, which you seem to have (the unresolved one :-().
> The linker would be in charge of linking that reference.
>