安装 Netcdf 4 时出现错误,找不到 hdf5 库的链接

安装 Netcdf 4 时出现错误,找不到 hdf5 库的链接

我正在尝试安装支持空气质量模型的 Netcdf 4,我将在完成此 netcdf 安装后对其进行编译。

然而,我遇到了“错误:无法找到或链接到 hdf5 库”,我从您的网站和其他网站上找到了几种解决方案,但是,都没有用。

我的安装步骤包括:

#install zlib:
tar xvzf zlib-1.2.11.tgz
cd zlib-1.2.11
mkdir /usr/local/zlib-1.2.11
./configure --prefix=/usr/local/zlib-1.2.11
make
make install
#install hdf5
tar xvzf hdf5-1.12.0.tar.gz
cd hdf5-1.12.0
mkdir /usr/local/hdf5-1.12.0
exportLDFLAGS=-L/usr/local/zlib-1.2.11
export FC=gfortran
./configure --prefix=/usr/local/hdf5-1.12.0 --enable-fortran
make
make install
#Install netcdf
tar xvzf netcdf-4.6.2.tar.gz
cd netcdf-4.6.2
mkdir /usr/local/netcdf-4.6.2
export CFLAGS=-I/usr/local/hdf5-1.12.0/include
export LDFLAGS=-L/usr/local/hdf5-1.12.0/lib
export LD_LIBRARY_PATH=/usr/local/hdf5-1.12.0/lib/
export FC=gfortran
./configure --prefix=/usr/local/netcdf-4.6.2

然后面临错误信息:

"checking for library containing H5Fflush... no
configure: error: Can't find or link to the hdf5 library. Use --disable-netcdf-4, or see config.log for errors."

我的笔记本电脑信息是:

Static hostname: it-Precision-7520
     Icon name: computer-laptop
       Chassis: laptop
  Operating System: Ubuntu 20.04.3 LTS
        Kernel: Linux 5.11.0-27-generic
  Architecture: x86-64

请告诉我问题可能出在哪里?我该如何解决?非常感谢。Chi

答案1

您不应该强制 Ubuntu 成为 LFS。您应该使用以下命令删除所有本地安装的内容:

cd /usr/local/zlib-1.2.11
sudo make uninstall

cd /usr/local/hdf5-1.12.0
sudo make uninstall

cd /usr/local/netcdf-4.6.2
sudo make uninstall

然后使用官方的 Ubuntu 存储库。它们提供所需的 hdf5净CDF
因此,要安装所有这些,您必须打开终端并执行以下命令:

sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install zlib1g-dev libhdf5-dev libnetcdf-dev

然后您将能够编译任何涉及这些库的应用程序。

相关内容