---
title: 安装HDF4
description: "1. 使用PuTTY工具，以root用户登录服务器。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpcindapp/prtg-osc/openmind_kunpengncl_02_0012.html
sourcePath: /source/zh/kunpenghpcs/hpcindapp/prtg-osc/openmind_kunpengncl_02_0012.html
indexId: a35e9e8ac0b67a64d49e150073499993f1ea47d073226a72ba02b723b344994274
---
# 安装HDF4

#### 操作步骤

1. 使用PuTTY工具，以root用户登录服务器。
2. 执行以下命令创建安装目录。

```
mkdir -p
/path/to/hdf4
```


3. 执行以下命令进入安装目录。

```
cd
/path/to/hdf4
```


4. 执行以下命令获得源码包。

```
wget
https://support.hdfgroup.org/ftp/HDF/releases/HDF4.2.15/src/hdf-4.2.15.tar.gz
```


5. 执行以下命令解压HDF4安装包。

```
tar -zxvf hdf-4.2.15.tar.gz
```


6. 执行以下命令进入解压后的目录。

```
cd hdf-4.2.15
```


7. 执行以下命令修改源码。

```
sed -i '974c #if defined(__linux__) && defined __x86_64__ && !( defined SUN) || defined(__aarch64__)' hdf/src/hdfi.h
sed -i '23660a LIBS="$LIBS -L/usr/lib64 -ltirpc"' configure
sed -i '23662c CPPFLAGS="$SYSCPPFLAGS -I/usr/include/tirpc"' configure
```


  需要依赖libtirpc-devel，请在部署前确保安装完成。此外，请在修改时添加libtirpc的实际路径，这里默认安装到/usr/include、/usr/lib64。

8. 执行以下命令配置。

```
export CC=mpicc CXX=mpicxx FC=mpifort
F77=mpifort
export
LIBJPEG_PATH
=
/path/to/libjpeg
./configure --prefix=
/path/to/hdf4
--enable-production --with-zlib=/usr/lib64 --enable-fortran --enable-hdf4-xdr --disable-shared --build=arm-linux  --with-jpeg=${LIBJPEG_PATH} --disable-netcdf CFLAGS="-fPIC -Wno-error=int-conversion" CXXFLAGS="-fPIC -Wno-error=int-conversion" FFLAGS="-fPIC -Wno-error=int-conversion -fallow-argument-mismatch" LDFALGS="-L/usr/lib64 -ltirpc"
```


9. 执行以下命令编译安装。

```
make -j 32
make install
```


10. 执行以下命令设置环境变量。

```
export PATH=
/path/to/hdf4
/bin:$PATH
export LD_LIBRARY_PATH=
/path/to/hdf4
/lib:$LD_LIBRARY_PATH
export INCLUDE=
/path/to/hdf4
/include:$INCLUDE
```
