Paul van Delst
2013-03-05 20:57:17 UTC
Hello,
Like the subject line says I'm trying to use the AC_SEARCH_LIBS macro
with a library written in Fortran95/2003. I'll start with the question I
end up asking at the end of this email:
Is there a way to specify a "custom" conftest.f90 for the AC_SEARCH_LIBS
macro like I can do with the AC_LINK_IFELSE macro?
The details:
My configure.ac contains
# Set the programming language
AC_LANG(Fortran)
AC_FC_FREEFORM
AC_FC_SRCEXT(f90)
# Check for libraries
AC_SEARCH_LIBS([CRTM_Version],
[crtm],[],
[AC_MSG_FAILURE([Unable to find CRTM library],[1])])
This fails and checking the config.log I see why:
configure:1933: checking for library containing CRTM_Version
configure:1946: gfortran -o conftest -I/CRTM/trunk/src/Build/include
-fno-second-underscore -fconvert=big-endian -ffree-form
-L/CRTM/trunk/src/Build/lib conftest.f90 -lCRTM >&5
/tmp/ccs2Fl97.o: In function `MAIN__':
conftest.f90:(.text+0x27): undefined reference to `crtm_version_'
collect2: ld returned 1 exit status
configure:1952: $? = 1
configure: failed program was:
| program main
| call CRTM_Version
| end
The test program is simply wrong (for Fortran90/95/2003/etc).
I scoured this mailing list and found the following discussions from
waaay back in 2008 and 2009:
http://lists.gnu.org/archive/html/autoconf/2008-03/msg00078.html
http://lists.gnu.org/archive/html/autoconf/2009-12/msg00003.html
The upshot from the knowledgable replies is that I shouldn't worry about
the "runability" of the test program, just the "linkability" since the
AC_SEARCH_LIBS is a generic test.
Well, the problem is that it seems the test program has to compile to an
executable state to not cause the linkerto return a failure status. This
means that the argument list of the function is question also has to be
specified - genericity (a word?) thus goes out the window.
The minimum code that will compile for my selected function is:
program main
use CRTM_Module
character(1) :: id
call CRTM_Version(id)
end
If I do the following in configure.ac:
AC_LINK_IFELSE(
[AC_LANG_SOURCE([program main; use CRTM_Module; character(1)::id;
call CRTM_Version(id); end])],
[],
[AC_MSG_FAILURE([Unable to link to CRTM library],[1])])
everything works. But, using this macro means @LIBS@ is not updated (and
I don't get the "checking for library containing CRTM_Version" info
output, but that's no biggie).
So, I'm at the asking point again: Is there a way to specify a "custom"
conftest.f90 for use "in" the AC_SEARCH_LIBS macro?
I tried using AC_LANG_CONFTEST to generate my custom conftest.f90, but
it wasn't used for the AC_SEARCH_LIBS case.
Thanks for any insight/help/suggestions/etc.
cheers,
paulv
Like the subject line says I'm trying to use the AC_SEARCH_LIBS macro
with a library written in Fortran95/2003. I'll start with the question I
end up asking at the end of this email:
Is there a way to specify a "custom" conftest.f90 for the AC_SEARCH_LIBS
macro like I can do with the AC_LINK_IFELSE macro?
The details:
My configure.ac contains
# Set the programming language
AC_LANG(Fortran)
AC_FC_FREEFORM
AC_FC_SRCEXT(f90)
# Check for libraries
AC_SEARCH_LIBS([CRTM_Version],
[crtm],[],
[AC_MSG_FAILURE([Unable to find CRTM library],[1])])
This fails and checking the config.log I see why:
configure:1933: checking for library containing CRTM_Version
configure:1946: gfortran -o conftest -I/CRTM/trunk/src/Build/include
-fno-second-underscore -fconvert=big-endian -ffree-form
-L/CRTM/trunk/src/Build/lib conftest.f90 -lCRTM >&5
/tmp/ccs2Fl97.o: In function `MAIN__':
conftest.f90:(.text+0x27): undefined reference to `crtm_version_'
collect2: ld returned 1 exit status
configure:1952: $? = 1
configure: failed program was:
| program main
| call CRTM_Version
| end
The test program is simply wrong (for Fortran90/95/2003/etc).
I scoured this mailing list and found the following discussions from
waaay back in 2008 and 2009:
http://lists.gnu.org/archive/html/autoconf/2008-03/msg00078.html
http://lists.gnu.org/archive/html/autoconf/2009-12/msg00003.html
The upshot from the knowledgable replies is that I shouldn't worry about
the "runability" of the test program, just the "linkability" since the
AC_SEARCH_LIBS is a generic test.
Well, the problem is that it seems the test program has to compile to an
executable state to not cause the linkerto return a failure status. This
means that the argument list of the function is question also has to be
specified - genericity (a word?) thus goes out the window.
The minimum code that will compile for my selected function is:
program main
use CRTM_Module
character(1) :: id
call CRTM_Version(id)
end
If I do the following in configure.ac:
AC_LINK_IFELSE(
[AC_LANG_SOURCE([program main; use CRTM_Module; character(1)::id;
call CRTM_Version(id); end])],
[],
[AC_MSG_FAILURE([Unable to link to CRTM library],[1])])
everything works. But, using this macro means @LIBS@ is not updated (and
I don't get the "checking for library containing CRTM_Version" info
output, but that's no biggie).
So, I'm at the asking point again: Is there a way to specify a "custom"
conftest.f90 for use "in" the AC_SEARCH_LIBS macro?
I tried using AC_LANG_CONFTEST to generate my custom conftest.f90, but
it wasn't used for the AC_SEARCH_LIBS case.
Thanks for any insight/help/suggestions/etc.
cheers,
paulv