This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Bug: Undefined reference to MAIN__
- To: martin dot kahlert at infineon dot com
- Subject: Re: Bug: Undefined reference to MAIN__
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- Date: Wed, 03 Oct 2001 00:12:51 +0200
- CC: gcc at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
- References: <20011001104419.A31910@keksy.muc.infineon.com>
Martin Kahlert wrote:
>
> This is a new bug (worked on Friday last weak):
> $ cat t.c
> int main()
> {
> extern void f_();
>
> f_();
> return 0;
> }
>
> $ cat f.f
> SUBROUTINE f
> WRITE(*,*) 'Hello World'
> RETURN
> END
>
> $ gcc -c t.c
> $ g77 -o t t.o f.f
> /sw/gcc-3.1/lib/gcc-lib/i686-pc-linux-gnu/3.1/frtbegin.o: In function `main':
> /home/kahlert/LOCAL/OBJ-3.1/i686-pc-linux-gnu/libf2c/libF77/../../../../gcc-3.1/libf2c/libF77/main.c:61:
> undefined reference to `MAIN__'
> collect2: ld returned 1 exit status
I think I solved this problem with the attached patch. If there's no
objection by tomorrow morning 8:00 C(entral) E(uropean) S(avings)
T(ime), which is, for those slow in time-related manners, UTC+2, I'll
apply it to the trunk.
Unfortunately, this patch doesn't solve the problem that one cannot run
the Fortran testsuite successfully without installing the compiler -
that's a problem I'm going to tackle tomorrow ...
Cheers,
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)
2001-10-03 Toon Moene <toon@moene.indiv.nluug.nl>
gcc/f/
* Make-lang.in: Remove reference to FORTRAN_INIT.
* g77spec.c: Add reference to FORTRAN_INIT.
libf2c/
* Makefile.in: Add "AR" reference, change
from frtbegin.o to libfrtbegin.a.
* libF77/Makefile.in: Ditto.
*** ./gcc/f/Make-lang.in.orig Tue Oct 2 19:49:02 2001
--- ./gcc/f/Make-lang.in Tue Oct 2 21:53:07 2001
*************** g77spec.o: $(srcdir)/f/g77spec.c $(srcdi
*** 74,78 ****
if [ -f lang-f77 ]; then \
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
- -DFORTRAN_INIT=\"$(libsubdir)/frtbegin.o\" \
$(srcdir)/f/g77spec.c $(OUTPUT_OPTION); \
else true; fi
--- 74,77 ----
*** ./gcc/f/g77spec.c.orig Sat Sep 29 12:41:48 2001
--- ./gcc/f/g77spec.c Tue Oct 2 21:52:50 2001
*************** Boston, MA 02111-1307, USA. */
*** 54,57 ****
--- 54,61 ----
#endif
+ #ifndef FORTRAN_INIT
+ #define FORTRAN_INIT "-lfrtbegin"
+ #endif
+
#ifndef FORTRAN_LIBRARY
#define FORTRAN_LIBRARY "-lg2c"
*** ./libf2c/Makefile.in.orig Mon Oct 1 01:03:19 2001
--- ./libf2c/Makefile.in Tue Oct 2 21:41:33 2001
*************** FLAGS_TO_PASS= \
*** 69,72 ****
--- 69,73 ----
CFLAGS='$(CFLAGS)' \
CPPFLAGS='$(CPPFLAGS)' \
+ AR='$(AR)' \
RANLIB='$(RANLIB)' \
prefix='$(prefix)' \
*************** install: all
*** 211,215 ****
mv $(LIBG2C_BASE).so* $(prefix)/lib ;\
fi)
! $(INSTALL_DATA) frtbegin.o $(libsubdir)
$(INSTALL_DATA) g2c.h $(libsubdir)/include/g2c.h
@if [ -f f2c-install-ok -o -f $(srcdir)/f2c-install-ok ]; then \
--- 212,217 ----
mv $(LIBG2C_BASE).so* $(prefix)/lib ;\
fi)
! $(INSTALL_DATA) libfrtbegin.a $(libsubdir)/$(MULTISUBDIR)
! $(RANLIB) $(libsubdir)/$(MULTISUBDIR)/libfrtbegin.a
$(INSTALL_DATA) g2c.h $(libsubdir)/include/g2c.h
@if [ -f f2c-install-ok -o -f $(srcdir)/f2c-install-ok ]; then \
*** ./libf2c/libF77/Makefile.in.orig Mon Oct 1 18:02:49 2001
--- ./libf2c/libF77/Makefile.in Tue Oct 2 20:33:06 2001
*************** CC = @CC@
*** 37,40 ****
--- 37,42 ----
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
+ AR = @AR@
+ ARFLAGS = rc
@SET_MAKE@
*************** OBJS = $(MISC) $(POW) $(CX) $(DCX) $(REA
*** 77,81 ****
$(HALF) $(CMP) $(EFL) $(CHAR) $(F90BIT)
! all: ../s-libf77 ../frtbegin.o
../s-libf77: $(OBJS)
--- 79,83 ----
$(HALF) $(CMP) $(EFL) $(CHAR) $(F90BIT)
! all: ../s-libf77 ../libfrtbegin.a
../s-libf77: $(OBJS)
*************** Makefile: Makefile.in config.status
*** 94,98 ****
config.status: configure
rm -f config.cache
! CONFIG_SITE=no-such-file CC='$(CC)' CFLAGS='$(CFLAGS)' \
CPPFLAGS='$(CPPFLAGS)' $(SHELL) config.status --recheck
--- 96,100 ----
config.status: configure
rm -f config.cache
! CONFIG_SITE=no-such-file CC='$(CC)' AR='$(AR)' CFLAGS='$(CFLAGS)' \
CPPFLAGS='$(CPPFLAGS)' $(SHELL) config.status --recheck
*************** VersionF.lo: Version.c
*** 104,110 ****
@LIBTOOL@ --mode=compile $(CC) -c $(ALL_CFLAGS) $(srcdir)/Version.c -o $@
! ../frtbegin.o : main.c
$(CC) -c $(ALL_CFLAGS) $(srcdir)/main.c -o $@
F77_aloc.lo: F77_aloc.c
s_rnge.lo: s_rnge.c
--- 106,116 ----
@LIBTOOL@ --mode=compile $(CC) -c $(ALL_CFLAGS) $(srcdir)/Version.c -o $@
! frtbegin.o : main.c
$(CC) -c $(ALL_CFLAGS) $(srcdir)/main.c -o $@
+ ../libfrtbegin.a: frtbegin.o
+ $(AR) $(ARFLAGS) $@ $<
+ $(RANLIB) $@
+
F77_aloc.lo: F77_aloc.c
s_rnge.lo: s_rnge.c
*************** check install uninstall install-strip di
*** 235,239 ****
mostlyclean:
! rm -f *.o *.lo ../frtbegin.o
rm -rf .libs
--- 241,245 ----
mostlyclean:
! rm -f *.o *.lo ../libfrtbegin.a
rm -rf .libs