[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to link other libraries to *my* library...
From: |
Philip Herron |
Subject: |
Re: how to link other libraries to *my* library... |
Date: |
Fri, 13 Nov 2009 16:29:10 +0000 |
Hey
Autoconf is what should handle your libraries etc:
bignum="no"
AC_ARG_WITH(bignum,
[AS_HELP_STRING([--with-bignum=yes/no],
[With GNU MP and MPFR multi-precision support, default no.])],
[bignum="$withval"])
if test "x$bignum" == "xyes"; then
AC_CHECK_LIB([gmp], [__gmpz_init], ,
[AC_MSG_ERROR([GNU MP not found, see http://gmplib.org/])])
AC_CHECK_LIB([mpfr],[mpfr_init] , ,
[AC_MSG_ERROR([MPFR not found, see http://www.mpfr.org/])])
AC_DEFINE([CONFIG_BIGNUM], 1, [Bignum multi-percision support])
AC_CHECK_SIZEOF(mp_limb_t, , [#include <gmp.h>])
CFLAGS="$CFLAGS -DBIGNUM"
fi
I use MPFR and GMP in one of my projects well its optional, but what
you should have in your configure.ac is the tests for the libraries
and the features your need on the system so what your interested is:
AC_CHECK_LIB([gmp], [__gmpz_init], ,
[AC_MSG_ERROR([GNU MP not found, see http://gmplib.org/])])
'gmp' from the -lgmp flag to the compiler the '__gmpz_init' symbol,
something i cant remember what to do on success i think and what to do
on failure. When your testing for all these features and libraries
autoconf handles all this so you should have anything in your
Makefile.am but your bin_PROGRAMS=... etc.. Hope this helps.
--Phil
2009/11/13 Ed Hartnett <address@hidden>:
> Howdy all!
>
> I am a programmer for netcdf, a set of free software libraries in C,
> C++, F77, and F90 for array-oriented access to scientific data. NetCDF
> is widely used in the Earth sciences and climate research.
>
> The netCDF C library uses other libraries, for example the hdf5,
> hdf5_hl, and zlib libraries. I was building the library without
> explicitly linking to these other libraries, assuming that libtool would
> magically handle this.
>
> But apparently not. One of my users complained, and now I have the
> following code in my Makefile.am:
>
> if USE_HDF4
> LDADD += -lmfhdf -ldf -ljpeg
> libnetcdf_la_LIBADD += -lmfhdf -ldf -ljpeg
> endif # USE_HDF4
>
> if USE_SZIP
> libnetcdf_la_LIBADD += -lsz
> endif # USE_SZIP
>
> LDADD += -lhdf5_hl -lhdf5 -lz
>
> if USE_PNETCDF
> LDADD += -lpnetcdf
> libnetcdf_la_LIBADD += -lpnetcdf
> endif
>
> Is there a better way to do this?
>
> Thanks,
>
> Ed
> --
> Ed Hartnett -- address@hidden
>
>
>