autoconf
[Top][All Lists]
Advanced

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

Re: AC_SEARCH_LIBS and fortran


From: Keith Marshall
Subject: Re: AC_SEARCH_LIBS and fortran
Date: Sat, 15 Mar 2008 11:43:25 +0000
User-agent: KMail/1.9.1

On Saturday 15 March 2008 02:57, JoeOutflow wrote:
> ... the -L flags should be contained in the LDFLAGS
> variable, but this is blank in the Makefiles. According to the manual
> LDFLAGS is a preset output variable and a search for "LDFLAGS"
> through the entire manual fails to turn up any explanation of how to
> append a library directory to LDFLAGS. Assigning it directly in
> configure.ac makes autoconf complain.

Autoconf doesn't automagically guess where you may have installed your 
libraries; if that isn't in any of the compiler's default search paths, 
then you have to tell it where to look. Normally, you shouldn't 
hardwire that into your configure script; you should leave it for the 
user to specify the LDFLAGS setting at configure time:

  path/to/configure LDFLAGS=/path/to/extra/libs ...

If you know, at autoconf time, where the extra libs path is likely to 
point, you can AC_SUBST some alternative PKG_LDFLAGS setting, and adapt 
your Makefile.in to also expand $(PKG_LDFLAGS) in the linking commands.  
It is bad manners to explicitly define LDFLAGS at autoconf time, as 
users expect to define it at configure time.

> Secondly the test program that configure attempts to compile is bound
> to fail even if all the "-L's" and "-l's" are exactly correct in the
> compile/link commands. This is because a number of necessary lines
> are missing from it. configure tries to compile:
>
> program test
> call h5open_f
> end program test

You are using AC_SEARCH_LIBS to confirm that some library in the libs 
path can furnish the h5open_f function/subroutine, right?  The test 
program doesn't have to be runnable; linkable is sufficient.  The above 
test program should admirably satisfy that requirement.

> but at minimum it must contain:
>
> program test
> use hdf5
> integer :: i
> call h5open_f(i)
> end program test

Why?  To be runnable, maybe, but it doesn't need to be runnable.

> Can this be arranged? If there was a subroutine in the library that
> didn't require an argument I'd have used it instead,

There is no opportunity for the test program to discover that the 
subroutine should have had an argument, until runtime.  AC_SEARCH_LIBS 
doesn't care, since it will never run this program; all it needs to 
know is that the symbol is exposed to the linker, no matter how many 
arguments it would normally take.

> ... there is still the need for the "use hdf5" statement.

It's been many years since I last wrote FORTRAN, and when I did, it was 
FORTRAN-77.  I've never written a `use' statement in a FORTRAN program, 
in my life, but if this has the effect of telling the compiler what the 
argument requirements for the test function are, then it would actually 
*damage* the test program, to specify it; let the compiler assume that 
the subprogram requires no arguments, so the test doesn't fail at 
compile time, and the linker can then report the symbol availability, 
which is what you really are trying to test.

Regards,
Keith.




reply via email to

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