Memo‎ > ‎

Build NetCDF4 for Visual Studio 2010 x64

posted Dec 22, 2012, 6:39 PM by Teng-Yok Lee   [ updated Feb 10, 2015, 11:25 PM ]
In order to run NetCDF for large data, I plan to build its x64 version. I tried several files from

The official Win32 releases from UCAR or via the official SVN case size_t to (signed) __int64, which can cause linking error.

The unofficial Win32 contributions are either too old or cannot be built.

The closest solution I found was release by Space Research. Their instructions are listed here, including the patched HDF5 and NetCDF 4.2. While their .sln files are for Win32 mode, it is easy to upgrade them to x64 version. The following instruction is my procedure. Note that my procedure make changes to the solution so szip is not required.

  1. Download the patched NetCDF and HDF5.
  2. Build HDF5
    1. Use VS2010 to open the .sln.
    2. Change the configuration from Win32 to x64
    3. Edit H5pubconf.h: Comment H5_HAVE_SZLIB_H, H5_HAVE_FILTER_SZIP, and H5_HAVE_TIMEZONE.
    4. Remove h5szip.c from the project
    5. Build hdf5 and hdf5_hl.
    6. Collect the .h to a folder (e.g. <hdf5_installed_dir>/include) and the .lib to a folder (e.g. <hdf5_installed_dir>/lib).
  3. Build NetCDF
    1. Use VS2010 to open the .sln.
    2. Change the configuration from Win32 to x64
    3. Build libsrc, libsrc4, libdispatch.
    4. I also built ncdump to test whether the libraries work.
    5. Collect the .h to a folder (e.g. <netcdf_installed_dir>/include), the .lib to a folder (e.g. <netcdf_installed_dir>/lib), and ncdump.exe to a folder (e.g. <netcdf_installed_dir>/bin).
  4. Use the files
    1. Include the files in
      • <hdf5_installed_dir>/include
      • <netcdf_installed_dir>/include
    2. Link the files in
      • <hdf5_installed_dir>/lib 
      • <netcdf_installed_dir>/lib
    3. Link the following libraries:
      • (Debug) <hdf5_installed_dir>/lib/hdf5d.lib
      • (Debug) <hdf5_installed_dir>/lib/hdf5_hld.lib
      • (Release) <hdf5_installed_dir>/lib/hdf5.lib
      • (Release) <hdf5_installed_dir>/lib/hdf5_hl.lib
      • <netcdf_installed_dir>/lib/libsrc.lib
      • <netcdf_installed_dir>/lib/libsrc4.lib
      • <netcdf_installed_dir>/lib/libdispatch.lib
PS. If you want to keep szip, you can download the official source code here released by the HDF group. This archive contains a CMakeLists.txt and thus building it should be straightforward.

Building HDF5/NetCDF4 with CMake?

PS. Now HDF5 can be built with CMake, and so does NetCDF 4.3.2 (See the two links below for more detail). So far I can use CMake to build HDF5, but I met issue with NetCDF (It cannot find zlib and there is no CMake entry for ZLIB_DIR).