Install netCDF under mac os

Gavin_fault發表於2019-05-10

Tips worth of notice

  • I`m using the cpp interfaces. It requires you first install the basic netCDF C class and then install the interface for cpp, because the cpp interface is based on the classic model.

  • netcdf.h is the header file for C interface; netcdfcpp.h is the older version of CPP version, and the newest version will use the header file netcdf instead.

  • Interfaces differ greatly between versions.

Installation

Use HomeBrew to install the package. Make sure you have the parameter. This is important to add support for c++.
brew install netcdf --with-cxx-compat

Compilation

Thanks to CodingAnarchy`s question, I found the missing parameter as followed. Otherwise, error keeps apearing that linking command fails.
g++ test.cpp -lnetcdf_c++4

Reference

Useful commands

  • brew doctor to analyze your condition of brew packages

11/14/2016 Weiming

相關文章