This is the mail archive of the
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
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
g77 foo.o -lfortlib
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
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
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.):
at a level accessible to physicists ;)