This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Bug: Undefined reference to MAIN__

I wrote:

>> I think I solved this problem with the attached patch.

> It appears to me that the problem is that the fortran shared 
> library is being linked with frtbegin.o, which is inappropriate.  
> My understanding is that shared libraries shouldn't be linked with
> frtbegin.o, only the main program should.

No, the problem was that the original g77spec.c code that Jurgen Pfeifer
introduced for dealing with a shared lib{f|g}2c *always* linked in
frtbegin.o, which contains the "real" main program for Fortran programs
compiled with g77.

Obviously, this is wrong if the main program is written in another
language than Fortran.

The way I solved it with my latest patch is that frtbegin.o now comes
from a library libfrtbegin.a (with a single object: frtbegin.o).  So now
it's only linked in with the program *iff* there's an unresolved `main',
which only is the case if the main program is written in Fortran.

Therefore, this should fix Martin Kahlert's bug report.  I checked and
it indeed did.

Toon Moene, KNMI, PO Box 201, 3730 AE De Bilt, The Netherlands.
Tel. +31302206443, Fax +31302210407,  e-mail

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]