[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fortran linking on NetBSD (was: autoconf-2.50 docs...)

From: Jason Beegan
Subject: Re: Fortran linking on NetBSD (was: autoconf-2.50 docs...)
Date: Fri, 01 Jun 2001 02:36:08 +0000

Steven G. Johnson wrote:
> Patrick Welche wrote:
> > A side issue, but related(?): the "checking for Fortran 77
> > name-mangling scheme" which fails for me (NetBSD-1.5V/i386,
> > egcs-2.91.66) is probably because:
> >     /usr/lib/ undefined reference to `MAIN__'
> > Jason Beegan suggested adding
> >       void MAIN__(void) { abort(); }
> > to the fortran program defining the subroutine foobar() (which would
> > then be called from C as foobar_())
> Hi, this concerns me.  First of all, this is not a bug in the
> name-mangling checks, it is a bug in AC_PROG_F77_LIBRARY_LDFLAGS, which is
> supposed to figure out how to link C programs to Fortran code/libraries.
> I don't like the solution of adding a dummy MAIN__() to the C program (I
> assume you don't mean the Fortran program!), because that would mean that
> *every* C program linking to Fortran code would have to be changed.

If you know of a better way.  I'd be grateful to know of it.

> It's much better if we can just figure out a proper LDFLAGS so that MAIN__
> is not needed.  (I'm surprised there is trouble here, since gcc on
> GNU/Linux has no problems.)  Any suggestions on what the flags are and how
> to detect them?

According to the source code I've been reading it *is* also a
GNU/Linux problem.  For example, octave, algae, tela, and others have
these hacks in the source code for GNU/Linux.  I usually just enable
them for NetBSD as well.

Excerpt from octave-2.0.16 liboctave/f2c-main.c:

> /* I think that this is really only needed if linking to Fortran
>    compiled libraries on a Sun.  It also seems to be needed on
>    some Linux/ELF systems with g77.  It should never be called. */
> #if defined (sun)
> int
> MAIN_ ()
> {
>   assert (0);
>   return 0;
> }
> #elif defined (__linux__)
> int
> MAIN__ ()
> {
>   assert (0);
>   return 0;
> }
> #endif

The octave has a similar dummy MAIN__(). 

You'll probably be saddened to hear that I added something similar to
the `configure' script for your FFTW library in the NetBSD Packages


reply via email to

[Prev in Thread] Current Thread [Next in Thread]