I ran into errors in the installation of the FDTD software MEEP on Ubuntu.Although I have hdf5-tools and libhdf5 installed on my system(Ubuntu 14.04.1 64-bit), the make step of the installation of MEEP returns an error as in this paste.bin link. I configured MEEP with the following command:

./configure --with-mpi --with-hdf5=/usr/lib/x86_64-linux-gnu/  > configure.out

I then ran make which resulted in error and I could not run make install afterwards. Without specifying the --with-hdf5 flag the configuration script used to return a warning as follows:

configure: WARNING: Couldn't find the HDF5 library!! Switching to ...

After installing numerous HDF5 libraries the problem was magically resolved; however, it was still present when I used the flag --with-hdf5=/usr/lib/x86_64-linux-gnu/. But without the flag everything installed flawlessly(I tested the program afterwards and confirmed that it was running as expected.) except the GNU Scientific Library linkage. My questions are as follows:

  1. How the location of the library can be located from the command prompt? Is executing the command locate hdf5 in the case of HDF5 and the finding the path of files ending with .so, .a enough?
  2. How could the GNU Scientific Library be introduced to the configuration and make scripts?
  3. Do the environmental variables LDFLAGS, CPPFLAGS and LD_LIBRARY_PATH have anything to do with the configuration and make scripts recognizing these libraries. I think they have since they are mentioned in MEEP install instructions and MEEP install tutorial. I would appreciate it if someone can explain how these and the LIB variable are related with installation procedures.

Thanks for taking your time,

P.S: If required I can supply additional documents. I did not put the configuration script etc. since I do not know which one is automatically generated and which one is not(same goes for make).

  • According to ./configure --help, the --with-hdf5 option seems to be boolean only (it doesn't take a <dir> argument). The hfd5 library should be discovered automatically provided you have installed the libhdf5-dev package in a "system" location (and possibly the appropriate libhdf5-mpi-dev if you are building --with-mpi i.e. either libhdf5-mpich2-dev or libhdf5-openmpi-dev). – steeldriver Dec 16 '14 at 15:53
  • @steeldriver Thanks for your comment. Apart from that how can I point out to GSL library? Furthermore, how are the other environmental variables related and are all the configure scripts alike since you told me this information without seeing the configure script? – Vesnog Dec 16 '14 at 21:29
  • I suspect it is finding the gsl library, but there is a wrinkle in exactly how it tests and reports it (specifically, that it does an AC_CHECK_FUNC rather than an AC_CHECK_LIB for the preceding libgslcblas library, which results in libgslcblas not getting added to $LIBS. However I don't know anywhere near enough about autoconf to say for sure. – steeldriver Dec 16 '14 at 22:21
  • @steeldriver I can provide the file if you wish or provide the link to the source directly. – Vesnog Dec 16 '14 at 22:26
  • Actually I already downloaded the meep tarball from the MIT website and had a play with it earlier. – steeldriver Dec 16 '14 at 22:35

To answer this question well really requires a thorough understanding of GNU autotools, which I don't have: nevertheless I hope these comments will help.

The configure script for a particular build is generated from its configure.ac file using autoconf. In turn, configure.ac uses standard macros to test for the presence of specified components. In this particular case, configure.ac specifies an AC_CHECK_LIB test for the GSL library as

  AC_CHECK_LIB(gsl, gsl_sf_bessel_Jn, [],
        [AC_MSG_WARN([Missing GNU GSL library...Bessel-function field initialization will not be supported.])])

The syntax of an AC_CHECK_LIB is

AC_CHECK_LIB (library, function, [action-if-found], [action-if-not-found], [other-libraries])

and the actual mechanism by which the check is performed is by creating a minimal test program (conftest) for the specified function gsl_sf_bessel_Jn in library libgsl, and attempting to link it using the default build tools. Such a minimal program might look something like

char gsl_sf_bessel_Jn();

int main() { return gsl_sf_bessel_Jn(); return 0; }

Note that the dummy prototype char gsl_sf_bessel_Jn() may bear no relation to the return type or argument list of the actual function - we never attempt to run the program, we just wish to know whether it links (i.e. whether the linker is able to resolve library references). We can see how this works if we create such a source file ourselves:

$ cat > conftest.c
char gsl_sf_bessel_Jn();

int main() { return gsl_sf_bessel_Jn(); return 0; }


As expected, if we try to run it without linking the GSL library, we get an error

$ gcc conftest.c
/tmp/ccWqFraS.o: In function `main':
conftest.c:(.text+0xa): undefined reference to `gsl_sf_bessel_Jn'
collect2: error: ld returned 1 exit status

However even if we explicitly link libgsl we find

$ gcc conftest.c -lgsl
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libgsl.so: undefined reference to `cblas_dasum'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libgsl.so: undefined reference to `cblas_sger'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libgsl.so: undefined reference to `cblas_zdotu_sub'
collect2: error: ld returned 1 exit status

At this point, it's important to note that the configure script doesn't know why a particular test has failed, only that it has. In this case, it has failed because we didn't link the subordinate libgslcblas library.

This illustrates the importance of the order in which tests are performed: each successful test causes the newly discovered library to be added to the $LIB variable for subsequent tests. Specifically (as noted in the GSL documentation)

It is important to check for libm and libgslcblas before libgsl, otherwise the tests will fail. Assuming the libraries are found the output during the configure stage looks like this,

checking for cos in -lm... yes 
checking for cblas_dgemm in -lgslcblas... yes 
checking for gsl_blas_dgemm in -lgsl... yes 

If the library is found then the tests will define the macros HAVE_LIBGSL, HAVE_LIBGSLCBLAS, HAVE_LIBM and add the options -lgsl -lgslcblas -lm to the variable LIBS.

The meep source package does check for libgslcblas before libgsl, however the specific check that it does is an AC_CHECK_FUNC rather than an AC_CHECK_LIB

AC_CHECK_FUNC(cblas_cgemm, [], [AC_CHECK_LIB(gslcblas, cblas_cgemm)])

While superficially similar, it appears that AC_CHECK_FUNC does not append the library to $LIBS on success; it appears we can work around this simply by adding an explicit AC_CHECK_LIB for libgslcblas in the configure.ac file

# GNU Scientific Library
AC_CHECK_FUNC(cblas_cgemm, [], [AC_CHECK_LIB(gslcblas, cblas_cgemm)])
AC_CHECK_LIB(gsl, gsl_sf_bessel_Jn, [],
   [AC_MSG_WARN([Missing GNU GSL library...Bessel-function field initialization will not be supported.])])

and then running autoconf to regenerate the configure script

$ autoconf

after which running ./configure reports that the the GSL library is indeed found:

$ ./configure --prefix=/usr/local | grep gsl
configure: WARNING: Cannot find latex2html in your path!
configure: WARNING: FFTW needed for MPB
checking for cblas_cgemm in -lgslcblas... yes
checking for gsl_sf_bessel_Jn in -lgsl... yes
  • Thanks for the comprehensive answer, I really appreciate the effort you put in writing these down. – Vesnog Dec 17 '14 at 16:06

apt-get install the packages from the http://packages.ubuntu.com/ repository. Ubuntu cache all the packages metadata in the computer. You can search your packages using the following command.

sudo apt-cache search "package keyword"

search the HDF5 library in the ubuntu package repository.

sudo apt-cache search "hdf5"

The command will show the packages relating to hdf5.

install the relevant package to you.

sudo apt-get install package-name. 

mostly you have to install the hdf5-tools, h5utils, python-tables.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.