linux下hdf5/netcdf的安装

一、环境ubuntu14.4

二、HDF5对NetCDF的支持 
1、需要下载的文件 
netcdf4.5、HDF5 1.8.9、zlib 1.2.5、curl 7.18.0版本不能低于这几个文件的版本,我使用的文件版本是netcdf4.5、hdf-1.10、zlib1.2.11、curl-7.57。 
netcdf下载地址:https://www.unidata.ucar.edu/downloads/netcdf/index.jsp 
HDF5下载地址:https://www.hdfgroup.org/downloads/ 
zlib下载地址:http://www.zlib.net/ 
curl下载地址:https://curl.haxx.se/download.html 
文件格式截图如下: 
 
下载时需要主要要下载源码。

这里写图片描述 

2、使用tar -zxvf +文件解压所有的文件

3、进入zlib的解压目录,编译安装zlib,输入下面的指令:

$ZDIR=/usr/local/
$sudo ./configure --prefix=${ZDIR}
$sudo make check 
//make check检测环境是否满足安装的要求,如果检测有错误,注意查看是否是你必须的,有些错误不用管,下同。
$sudo make install 

4、进入curl的解压目录,编译安装curl,输入下面的指令:
$CURLDIR=/usr/local/
$ sudo ./configure --prefix=${CURLDIR}
$sudo make check
$sudo make install 

5、进入HDF5的解压目录,编译安装HDF5,输入下面的指令:
$H5DIR=/usr/local/
$ sudo ./configure --width-zlib=${ZDIR} --prefix=${H5DIR} 
//此处官网后面加了--eanble-hl,我的编译不过,去掉就可以啦,没有发现什么影响
$sudo make check
$sudo make install 

6、进入NetCDF的解压目录,编译安装NetCDF,输入下面的指令:
$NCDIR=/usr/local/
$ sudo CPPFLAGS=-I${H5DIR}/include LDFLAGS=-L${H5DIR}/lib ./configure --prefix=${NCDIR}
$sudo make check
$sudo make install 
这一步可能会出现undefined reference to `curl_easy_init'错误,解决办法:makefile 中加入   LIBS+=-lcurl
至此NetCDF就安装好啦,并且也支持HDF5啦。
 

三、HDF4对NetCDF的支持 
1、需要下载的文件:HDF-4.2、libjpeg-6b,截止到本文下载的都是官方最新的。 
hdf4下载地址:https://support.hdfgroup.org/products/hdf4/ 
libjpeg-6b下载地址:http://www.linuxfromscratch.org/blfs/view/6.3/general/libjpeg.html 
文件格式截图:
这里写图片描述 

下载时需要主要要下载源码。 
2、使用tar -zxvf +文件解压所有的文件。

3、进入NetCDF文件目录,编译安装HDF4。
$sudo ./configure --enable-shared --disable-netcdf --disable-fortran --prefix=${H4DIR}
$sudo make check
$sudo make install

4、编译安装HDF4对NetCDF4的支持,命令如下:
$sudo CPPFLAGS="-I${H5DIR}/include -I${H4DIR}/include"  LDFLAGS="-L${H5DIR}/lib -L${H4DIR}/lib" ./configure --enable-hdf4 --enable-hdf4-file-tests --disable-fortran
$sudo make check
$sudo make install
这一步安装上可能就没有那么顺利啦,会出现很多的问题,问题和解决办法总结如下:
1》、出现错误:cannot compile a simple Fortran program 安装时可以忽略,上面指令中已经忽略啦,加红部分。
2》、出现错误:cannot find yacc utility 安装sudo apt-get install byacc。
3》、出现错误:cannot find lex utility 安装sudo apt-get install flex。
4》、出现错误:couldn't find jpeg library 缺少库libjpeg-6b,之前下载好的在这个地方用到了。
安装方法,进入libjpeg解压目录执行下面命令,可能会出现5》的问题,解决办法看5》:
xxx/jpeg-6b$ sudo ./configure --prefix=/usr/local --enable-static --enable-shared && make
xxx/jpeg-6b$ sudo make install
5》、make: ./libtool: Command not found  安装sudo apt-get install libtool
拷贝下面的连个文件到libjpeg解压目录下,注意下面指令后面的点(点指的是当前目录即libjpeg所在目录
):
cp /usr/share/libtool/config/config.sub .
cp /usr/share/libtool/config/config.guess .
xxx/jpeg-6b$ make clean
xxx/jpeg-6b$ sudo ./configure --prefix=/usr/local --enable-static --enable-shared && make
xxx/jpeg-6b$ sudo make install

这一步还可能出现6》的问题,解决办法看6》。
6》、./ncgen: error while loading shared libraries: libjpeg.so.62: cannot open shared object file: No such file or directory
解决方案:http://blog.csdn.net/dumeifang/article/details/2963223 || http://blog.csdn.net/david_xtd/article/details/7625626/
我的指令如下:
/etc/ld.so.conf.d$ sudo vi libjpeg.conf 
/etc/ld.so.conf.d$ sudo chmod u+rwx libjpeg.conf
文件中加入:/usr/local/lib并保存
运行/etc/ld.so.conf.d$ sudo ldconfig刷新
5、当你看到下面的下面的信息时,说明HDF4对NetCDF4支持成功啦,截图: 

这里写图片描述

猜你喜欢

转载自blog.csdn.net/Leo_csdn_/article/details/84306399