This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
linking c code against fortran libraries
- From: Craig Maloney <cmaloney at physics dot ucsb dot edu>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 28 Jan 2004 09:24:37 -0800 (PST)
- Subject: linking c code against fortran libraries
Hi all.
I have some questions about linking c code against fortran libraries.
Suppose I have a code foo.c which calls routines in a fortran library
libfortlib.
First question:
is
g77 foo.o -lfortlib
equivalent to
gcc foo.o -lfortlib -lfrtbegin -lg2c -lm -shared-libgcc
or does it actually matter that the compiler was invoked as g77.
At any rate, neither of these is successful and give equivalent error:
gcc-3.2.1/i686-pc-linux-gnu/libf2c/libF77/main.c: undefined reference to
`MAIN__'
It was my understanding that linking with g77 was supposed to tie up the
stuff so that the entry point into the executable was somewhere in
libfrtbegin which then called foo.o:main() after libg2c initialization.
The library is a debian build (OK, I might as well be specific -- it's
lapack) but the behavior doesn't seem to depend on whether I compile and
link with any of the debian build gcc's (2.95, 3.0, 3.0.4) or a handbuilt
3.2.1.
If no one has the magic solution for me, what might be even better is if
someone at least has some pointers to discussions where these issues are
raised (other than (e.g.):
http://gcc.gnu.org/onlinedocs/gcc-3.3.2/g77/Startup-Code.html#Startup%20Code
)
at a level accessible to physicists ;)
Cheers,
Craig