在Linux上安装netcdf4 ,解决"Can't find or link to the hdf5 library"的问题

2 Quick Instructions for Installing NetCDF on Unix

Who has time to read long installation manuals these days?

When building netCDF-4, you must first decide whether to support the use of HDF5 as a storage format.

2.1 Building NetCDF Without HDF5

If you don't want netCDF-4/HDF5, then build like this:

     ./configure --prefix=/home/ed/local --disable-netcdf-4
     make check install

(Replace “/home/ed/local” with the name of the directory where netCDF is to be installed.)

If you get the message that netCDF installed correctly, then you are done!

2.2 Building NetCDF With HDF5

If you want to use the HDF5 storage format, you must have the HDF5 1.8.6 release. You must also have the zlib compression library, version 1.2.5. Both of these packages are available from the netCDF-4 ftp site atftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.

Make sure you run “make check” for the HDF5 and zlib distributions. They are very well-behaved distributions, but sometimes the build doesn't work (perhaps because of something subtly misconfigured on the target machine). If one of these libraries is not working, netCDF will have serious problems.

Optionally, you can also build netCDF-4 with the szip 2.0 library (a.k.a. szlib). NetCDF cannot create szipped data files, but can read HDF5 data files that have used szip.

There are license restrictions on the use of szip, see the HDF5 web page: http://hdf.ncsa.uiuc.edu/doc_resource/SZIP/Commercial_szip.html. These license restrictions seem to apply to commercial users who are writing data. (Data readers are not restricted.) But here at NetCDF World Headquarters, in Sunny Boulder, Colorado, there are no lawyers, only programmers, so please read the szip documents for the license agreement to see how it applies to your situation.

If you wish to use szip, get it from the HDF5 download page: http://hdfgroup.org/HDF5//HDF5/release/beta/obtain518.html.

If “make check” fails for either zlib or HDF5, the problem must be resolved before the netCDF-4 installation can continue. For HDF5 problems, send email to the HDF5 help desk: help@hdfgroup.org.

Build zlib like this:

     ./configure --prefix=/home/ed/local
     make check install

Then you build HDF5, specifying the location of the zlib library:

     ./configure --with-zlib=/home/ed/local --prefix=/home/ed/local
     make check install

Note that for shared libraries, you may need to add the install directory to the LD_LIBRARY_PATH environment variable. See the FAQ for more details on using shared libraries:http://www.unidata.ucar.edu/netcdf/faq.html.

If you are building HDF5 with szip, then include the –with-szlib= option, with the directory holding the szip library.

After HDF5 is done, build netcdf, specifying the location of the HDF5, zlib, and (if built into HDF5) the szip header files and libraries in the CPPFLAGS and LDFLAGS environment variables.

     CPPFLAGS=-I/home/ed/local/include LDFLAGS=-L/home/ed/local/lib ./configure --prefix=/home/ed/local
     make check install

Howdy Stephen!

The --with-hdf5 option has been removed from 4.1.3 (the current release)
and will not be in any future releases.

It might seem more robust, but it is not. It fails badly in the area of
32/64 bit platforms (i.e. platforms that want both a 32 bit and a 64 bit
version of the library installed at the same time.) It also adds a lot
of code to our build system.

The correct way to solve this is with the environment variables, which
leaves full control in the hands of the hands of the user.

The use of the --with options was an plot perpetrated by my evil twin,
who hates netCDF and all it stands for. He roams the Earth, attempting
to convince scientists to store their data in undocumented binary
formats. It makes for an awkward Thanksgiving dinner, but that's family
for you.

Thanks,

cd ../zlib-1.2.5
./configure --prefix=/usr/local/mylib
make check install -j 4

//---------------------------------------------------------------------------

cd hdf5-1.8.7
./configure --with-zlib=/usr/local/mylib --prefix=/usr/local/mylib
make check -j 5
make install

//---------------------------------------------------------------------------

export CPPFLAGS=-I/usr/local/mylib
export LDFLAGS=-L/usr/local/mylib
export LD_LIBRARY_PATH=/usr/local/mylib

//---------------------------------------------------------------------------

 

修改/etc/profile 改环境变量参数
export NETCDF=/usr/local/netcdf4
PATH=$PATH:$NETCDF/bin

 

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值