This is the mail archive of the gcc-help@gcc.gnu.org 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: Linking c and fortran code


Hi Chris

I don't know the innards of the current compilers, but this is not, in
general a simple thing to do. Particularly when trying to mix compilers from
different companies. You need to be absolutely clear that you have a clear
mapping between all data types (and that your programs are coded
accordingly). You need a common calling convention (Fortran: called
subroutine pops the stack - to reduce code generated when sub called from
many places, C calling function pops the stack as called doesn't know how
many parameters there were; what order are parameters pushed, etc.)

If this is an app that was built like this deliberately for another
platform, you may have some luck, otherwise you may have a deal of work to
do.

good luck

tim
----- Original Message -----
From: <chris@frostnet.net>
To: <gcc-help@gcc.gnu.org>
Sent: Friday, June 22, 2001 2:23 PM
Subject: Linking c and fortran code


> I'm trying to build an application written in C and Fortran but am having
> trouble linking the fortran and c object files.
>
> I've compiled the c code with gcc under cygwin, and the fortran code with
> microsoft's fortran compiler (there is a large amount of fortran 90 and 95
> code which g77 doesn't grok). When linking the resultant object files, ld
> can't find the required symbols for a few std fortran calls, a lot of Xt
and
> standard C calls (eg printf or strlen), and none of the c code seems to be
> able to resolve symbols provided by the fortran code.
>
> If I add an extra underscore to the required symbol names for at least
> standard fortran calls to the object files for the fortran code, they
> sometimes will resolve (so __foo instead of _foo).
>
> I'm linking in the Mrm, Xm, Xt, Xaw, X11, SM, ICE, and math libraries (in
> that order).
>
> Should it be possible to link code like this? Is there anything I could
> read to try to figure out what else I need to be doing? Or any suggestions
> on what I've left out?
>
> Sorry that this is a bit off topic; I asked the general cygwin group and
> didn't get any responses.
>
> a big thanks in advance!
> --
> Chris Frost  |  <http://www.frostnet.net/chris/>
> -------------+----------------------------------
> Public PGP Key:
>    Email chris@frostnet.net with the subject "retrieve pgp key"
>    or visit <http://www.frostnet.net/chris/about/pgp_key.phtml>
>


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