[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Proper way to link Fortran with C++

From: Steven G. Johnson
Subject: Re: Proper way to link Fortran with C++
Date: Wed, 24 Feb 2010 17:37:58 -0500
User-agent: Thunderbird (Macintosh/20090812)

Ralf Wildenhues wrote:
The Automake documentation on the other hand states that I should put $(FLIBS)
into the apropriate _LDADD or _LIBADD variable.  That would include the value
of FLIBS before the value of LIBS on the linker command line, contradicting
the autoconf documentation.

Is there a reason Autconf requires FLIBS after LIBS, and not just FLIBS after
the library actually using fortran?  That would be


in the case of blas, and it would allow me to fold FLIBS into BLAS_LIBS.  This
in turn would make it easier to omit the FLIBS completely in case blas was not
detected by configure.

Do you remember why the Autoconf macro specifically recommends
this ordering?  We should amend it with a rationale.

I couldn't find anything in the archives of the macro sources about it.
Maybe it is because $LIBS may contain a Fortran library?


The only reason to check for FLIBS is to link to Fortran libraries from a non-Fortran program. And the standard way to check for libraries is to use AC_CHECK_LIB, which by default adds the library to LIBS, rather than using a separate variable ala BLAS_LIBS (and often people who use e.g. ACX_BLAS just add $BLAS_LIBS to LIBS).

Also, putting libraries into LIBS is important for several other autoconf macros to work normally, e.g. AC_CHECK_FUNC.

So, the point is to allow people to use AC_CHECK_LIB normally after calling AC_F77_LIBRARY_LDFLAGS (and possibly AC_F77_FUNC to find the appropriate C linker name for a Fortran identifier).

Steven G. Johnson

reply via email to

[Prev in Thread] Current Thread [Next in Thread]