[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] Building a shared library that links with GSL
From: |
John D Lamb |
Subject: |
Re: [Help-gsl] Building a shared library that links with GSL |
Date: |
Wed, 02 May 2007 18:10:23 +0100 |
On Wed, 2007-05-02 at 11:58 +0100, Joseph Wakeling wrote:
> I'm building a small simulation library that makes use of some GSL
> functions. However, I'm a novice with autotools and I'm having some
> trouble working out how to check that GSL is installed and its header
> files are in place.
>
> What lines do I need to add to configure.ac to make sure that GSL is
> present and correct with necessary files for development?
Here's what I use:
dnl Check for libtool
AC_ENABLE_SHARED
AC_PROG_LIBTOOL
dnl Checks for libraries.
AC_CHECK_LIBM
use_atlas=yes
AC_CHECK_LIB([atlas],[main],[],[use_atlas=no])
if test x$use_atlas = xyes; then
AC_CHECK_LIB([f77blas],[main],[],[use_atlas=no])
fi
if test x$use_atlas = xyes; then
AC_CHECK_LIB([cblas],[main],[],[use_atlas=no])
fi
if test x$use_atlas = xyes; then
AC_CHECK_LIB([lapack],[main],[],[use_atlas=no])
fi
if test x$use_atlas = xno; then
AC_CHECK_LIB([gslcblas],[main],[],[
echo \
"------------------------------------------------------------------------
ERROR: Could not find a CBLAS implementation.
Tried both ATLAS cblas and gslcblas.
------------------------------------------------------------------------"
exit
])
fi
AC_CHECK_LIB([gsl],[main],[],[
echo \
"------------------------------------------------------------------------
ERROR: libgsl appears to be missing. You cannot sanely try to build
XXXX without libgsl, the GNU Scientific Library. It is available from
http://www.gnu.org/ and compiles readily on most systems.
------------------------------------------------------------------------"
exit
],[-lgslcblas])
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([gsl/gsl_version.h],[],[
echo \
"------------------------------------------------------------------------
ERROR: libgsl is present, but the header files appear not to have been
installed. If the GNU Scientific Library was installed as an RPM or
similar, make sure you also include the -devel package. Otherwise, you
can obtain the GNU Scientific Library from http://www.gnu.org.
------------------------------------------------------------------------"
exit
])
> Secondly, do I need to reference -lgsl -lgslcblas when compiling my
> library, or can I leave this in the hands of the person compiling a
> program that makes use of it? I have created an appropriate .pc file
> for pkg-config.
I don't use pkg-config. The AC_CHECK_LIB macro in configure.ac will
prepend -lgsl to the list of compiler flags. It will also define the
preprocessor macro HAVE_LIBGSL so that you can use, for example,
#ifdef HAVELIBGSL
// smart code
#else
// alternative code
#endif
Since this is useless to me (aut GSL aut nihil) I've simply put out
errors and forced an exit in the absence of GSL.
--
JDL