您的位置:首页 > 运维架构 > Linux

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

2012-04-12 21:05 1116 查看

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 href="http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-install/Quick-Instructions.html" target=_blank>.

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

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐