[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Mixing Fortran and C: how to force the linking with CC?
From: |
Ralf Wildenhues |
Subject: |
Re: Mixing Fortran and C: how to force the linking with CC? |
Date: |
Wed, 28 May 2008 06:21:51 +0200 |
User-agent: |
Mutt/1.5.17+20080114 (2008-01-14) |
Hello Sebastien,
* Sebastien Maret wrote on Wed, May 28, 2008 at 02:08:21AM CEST:
>
> I am using autoconf and automake for a code written in Fortran and
> C. The main program is written in C; Fortran routines are used to do
> numerical computations.
> AC_PROG_CC
> AC_PROG_FC
> AC_FC_WRAPPERS
> myprog_SOURCES = myprog.c myprog.h subroutine1.f subroutine2.f
>
> For some reason, the final linking is done with FC. This works fine
> CC=gcc and FC=gfortran, but fails with CC=icc and FC=ifort, because
> _main is defined in both myprog.o and one of the Fortran compiler
> libraries. It works fine when the final link is done with CC.
>
> Is there a way to force the final linking with CC instead of FC?
Yes, you can munge with myprog_LINK if you have to, see
<http://www.gnu.org/software/automake/manual/html_node/Program-and-Library-Variables.html>
However, in this special case, I think you can get away with using
AC_FC_DUMMY_MAIN as described in
<http://www.gnu.org/software/autoconf/manual/html_node/Fortran-Compiler.html>
which is better in that it alleviates you from redoing the choice for
every compiler combination out there.
Hope that helps.
Cheers,
Ralf