Search code examples
shared-librarieshdf5netcdf

'Can't find hdf5 library' while installing netCDF4


I am trying to build NetCDF4 from source on MacOSX. When I run ./configure I get the error:

checking for library containing H5Fflush... no
configure: error: Can't find or link to the hdf5 library. Use --disable-netcdf-4, or     see config.log for errors.

I installed hdf5 before, and set the environment variables as:

LDFLAGS=-L/opt/local/lib
CPPFLAGS=-I/opt/local/include

In /opt/local/lib I have these files:

libhdf5.8.dylib             
libhdf5.a               
libhdf5.dylib               
libhdf5.settings            
libhdf5_cpp.8.dylib         
libhdf5_cpp.a               
libhdf5_cpp.dylib           
libhdf5_hl.8.dylib          
libhdf5_hl.a                
libhdf5_hl.dylib            
libhdf5_hl_cpp.8.dylib          
libhdf5_hl_cpp.a            
libhdf5_hl_cpp.dylib

And in /opt/local/include I have:

hdf5.h      hdf5_hl.h

Why doesn't the configure script find the hdf5 library? I am happy to provide more information if needed!

EDIT: My ultimate goal is to install netcdf4 for use as a Fortran module. I have tried installing everything through MacPorts, and it seemed to work, but when I tried to use it, the compiler told me that there was no netcdf.mod file, and sure enough there wasn't one to be found anywhere. It turns out that just typing:

sudo port install netcdf-fortran

only installs the library files, but doesn't create a .mod file, which I guess is needed. So I found out that other people had the same problem, and the advice given was to install it with gcc44, which did create a .mod file, but then my compiler told me that the .mod file was built with a different version of gfortran and it couldn't be used, so that's why I am trying to build it from scratch, but if someone has a faster option, I would be more than happy to try it!


Solution

  • Ok, I finally figured it out. I reinstalled netcdf-fortran with macports, then the .mod file suddenly appeared, I then had the problem, however, that when running gfortran, it would tell me that netcdf.mod was compiled with a different version of fortran than the one I am using. (Macports uses 4.8), so got gcc48 from macports and am using gfortran-mp-4.8 to compile now and it works.

    Still don't know how to build all these things from scratch, but it works now at least!!!