Compiling 64-bit NetCDF4 with HDF5 on Mac OS X

I needed a 64-bit version of HDF5 and NetCDF4, here’s how you get that going on Mac OS X 10.6.

  1. Download the and uncompress the static HDF5 1.8.6 binaries.
  2. Download the and uncompress the NetCDF 4.1.2 source.
  3. Get rid of all of the .la files in the HDF5 libs folder.
  4. From the command line, set the following environmental variables,
    export CC='gcc' CFLAGS='-g -m64' CFLAGS='-g -m64' CXXFLAGS='-g -m64' HDF5DIR='/path/to/hdf5/folder' LIBS='-lsz' LDFLAGS='-L/path/to/hdf5/folder/lib' You will obviously have to use the true path to the folder.
  5. Make sure you’re in the NetCDF folder and run the following,
    ./configure --disable-f77 --disable-f90 --target=x86_64-apple-darwin -build=x86_64-apple-darwin --host=x86_64-apple-darwin --with-hdf5=$HDF5DIR --with-zlib=$HDF5DIR --with-szlib=$HDF5DIR --enable-shared

I ran make check and everything worked well. I just wanted the resulting libraries, which can be found in liblib/.libs/, but I’m sure you can do a make install if you actually want to install the libraries.

One thought on “Compiling 64-bit NetCDF4 with HDF5 on Mac OS X”

Comments are closed.