autoconf
[Top][All Lists]
Advanced

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

Re: question about using AC_SEARCH_LIBS with fortran...


From: Ralf Wildenhues
Subject: Re: question about using AC_SEARCH_LIBS with fortran...
Date: Wed, 2 Dec 2009 08:02:14 +0100
User-agent: Mutt/1.5.20 (2009-08-09)

Hi Ed,

* Ed Hartnett wrote on Wed, Dec 02, 2009 at 01:26:02AM CET:
> I am trying to use the AC_SEARCH_LIBS macro to find a fortran library.

I think that should work as expected.

> But what if it is installed in a standard location, like /usr/local?
> When I test for C libraries, I don't have to put a -I/usr/local/include
> in CPPFLAGS, it just finds it there. 

Generally, it can depend on the compiler driver and/or the link editor
whether /usr/local/lib is searched by default for libraries; and the
compiler driver or preprocessor whether /usr/local/include is searched
by default for included header files.

> Why can't fortran do the same thing?

Well, so far I'm not sure it just does the same thing on your system,
because you haven't shown that yet; see below.

> Also, I agree with the poster on that thread who contends that fortran
> will not correctly compile the test program conftest.f with the use
> LIBRARY statement.

FWIW, I don't understand this sentence.

> I am trying to get my library (libcf) to find another fortran library
> that should be already installed: the netCDF library. I am trying this:
> 
>    AC_LANG_PUSH(Fortran)
>    AC_FC_SRCEXT(f90)
>    AC_SEARCH_LIBS([nf90_open], [netcdf])
>    AC_LANG_POP(Fortran)
> 
> Which generates the following test program:
> configure:5217: gfortran -o conftest -g -O2   conftest.f90  >&5
> /tmp/ccaZquLl.o: In function `main':
> /home/ed/snapshot/lb_new2/conftest.f90:2: undefined reference to
> `nf90_open_'
> collect2: ld returned 1 exit status
> configure:5217: $? = 1
> configure: failed program was:
> |       program main
> |       call nf90_open
> |       end


The AC_SEARCH_LIBS will generate up to two link tests, one without
-lnetcdf and one with -lnetcdf in the command line.  You only showed how
things failed without.  It is quite well possible the next one, with
-lnetcdf, will successfully link.

Can you please confirm that, or otherwise show how it fails?
If it fails, can you retry with
  ./configure LDFLAGS=-L/usr/local/lib

?

> In fact, the smallest test program I can get gfortran to compile is:
> 
> program main
>   use netcdf
>   res = nf90_open('lll', 0, ncid)
> end program main

But surely you added something like -lnetcdf to the link command line,
no?

I'm not actually sure whether the lack of the "use netcdf" line in the
configure-generated test poses a problem or not, but I would think that
it doesn't, given that Fortran does not cause name mangling.

Hope that helps.

Cheers,
Ralf




reply via email to

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