C/C++教程

NetCDF库编译安装

本文主要是介绍NetCDF库编译安装,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1. 准备

系统环境,全部是deepin系统自带,并无单独安装

deepin 20.6
gcc 8.3.0
g++ 8.3.0
cmake 3.22.1 

netcdf安装版本:此次使用最新4.9.0,系统为deepin 20.6,大于4.3.0

源码下载地址,下载netcdf-c-4.9.0.tar.gz:

https://downloads.unidata.ucar.edu/netcdf/

 

netCDF-C Source Code

· CMake version 2.8.12 or greater.

· Optional Requirements:

o HDF5 Libraries for netCDF4/HDF5 support.

o libcurl for DAP support.

 

 2. 安装步骤

1. 需要先安装HDF5

2. 编译安装NetCDF

 

 3. 编译安装HDF5

下载源码包

https://www.hdfgroup.org/downloads/hdf5/

 

 解压后依次执行

sudo ./configure --prefix=/usr/local/hdf5

sudo make

sudo make install

sudo apt install hdf5-helpers
sudo apt-get install libhdf5-serial-dev

cd /usr/local/hdf5/share/hdf5_examples/c

sudo ./run-c-ex.sh

sudo h5cc -o h5_extend h5_extend.c

sudo ./h5_extend

4. 编译安装NetCDF

sudo apt install m4

sudo ./configure --prefix=/usr/local/netcdf4 LDFLAGS=-L/usr/local/hdf5/lib CPPFLAGS=-I/usr/local/hdf5/include

sudo make
sudo make install

5. 参考文档

[1].https://docs.unidata.ucar.edu/netcdf-c/current/netCDF-CMake.html

[2].https://www.cnblogs.com/zhml/p/15102214.html

[3].https://blog.csdn.net/skyvoice2/article/details/7455527

 

 

这篇关于NetCDF库编译安装的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!