Ubuntu下安裝h5check

前言

筆者照著h5check官網上給出的安裝說明實作,卻還是踩了一些坑。本篇詳細紀錄了h5check從下載、解壓縮、建構、安裝到測試的詳細流程,希望能幫到有需要的同學。

H5CHECK簡介

h5check是用來檢查hdf5檔案正確性的工具,H5CHECK: THE HDF5 FORMAT CHECKER
是它的官方網頁。

下載

首先從H5CHECK下載頁面下載h5check-2.0.1.tar.gz檔案。

wget https://support.hdfgroup.org/ftp/HDF5/tools/h5check/src/h5check-2.0.1.tar.gz -O h5check-2.0.1.tar.gz

解壓縮

tar xvzf h5check-2.0.1.tar.gz

建構

cd h5check-2.0.1
./configure
make

注:根據How can I get gmake?這則討論串,在Ubuntu中,make就相當於gmake的角色,因此將官方安裝說明中的gmake都改用make替代。
這時出現以下錯誤訊息:

Making all in src
make[1]: Entering directory ‘/root/h5check-2.0.1/src’
make all-am
make[2]: Entering directory ‘/root/h5check-2.0.1/src’
gcc -DHAVE_CONFIG_H -I. -g -O2 -MT h5checker.o -MD -MP -MF .deps/h5checker.Tpo -c -o h5checker.o h5checker.c
h5checker.c: In function ‘G_dense_ck_fh_msg_cb’:
h5checker.c:6716:10: warning: implicit declaration of function ‘build_name’ [-Wimplicit-function-declaration]
if(build_name(file->shared->extpath, tmp_name, &full_name/out/) < 0) {
^
h5checker.c: In function ‘file_init’:
h5checker.c:8116:24: warning: implicit declaration of function ‘build_extpath’ [-Wimplicit-function-declaration]
if(g_follow_ext && build_extpath(fname, &(thefile->shared->extpath)) < 0) {
^
mv -f .deps/h5checker.Tpo .deps/h5checker.Po
gcc -DHAVE_CONFIG_H -I. -g -O2 -MT h5checker_api.o -MD -MP -MF .deps/h5checker_api.Tpo -c -o h5checker_api.o h5checker_api.c
mv -f .deps/h5checker_api.Tpo .deps/h5checker_api.Po
gcc -DHAVE_CONFIG_H -I. -g -O2 -MT h5error.o -MD -MP -MF .deps/h5error.Tpo -c -o h5error.o h5error.c
mv -f .deps/h5error.Tpo .deps/h5error.Po
gcc -DHAVE_CONFIG_H -I. -g -O2 -MT h5checkerV2_0.o -MD -MP -MF .deps/h5checkerV2_0.Tpo -c -o h5checkerV2_0.o h5checkerV2_0.c
mv -f .deps/h5checkerV2_0.Tpo .deps/h5checkerV2_0.Po
gcc -DHAVE_CONFIG_H -I. -g -O2 -MT h5pline.o -MD -MP -MF .deps/h5pline.Tpo -c -o h5pline.o h5pline.c
mv -f .deps/h5pline.Tpo .deps/h5pline.Po
rm -f libh5check.a
ar cru libh5check.a h5checker.o h5checker_api.o h5error.o h5checkerV2_0.o h5pline.o
ar: u' modifier ignored sinceD’ is the default (see `U’)
ranlib libh5check.a
make[2]: Leaving directory ‘/root/h5check-2.0.1/src’
make[1]: Leaving directory ‘/root/h5check-2.0.1/src’
Making all in tool
make[1]: Entering directory ‘/root/h5check-2.0.1/tool’
gcc -DHAVE_CONFIG_H -I. -I…/src -I…/src -g -O2 -MT h5checker_main.o -MD -MP -MF .deps/h5checker_main.Tpo -c -o h5checker_main.o h5checker_main.c
mv -f .deps/h5checker_main.Tpo .deps/h5checker_main.Po
gcc -g -O2 -o h5check h5checker_main.o …/src/libh5check.a -lm -lz
make[1]: Leaving directory ‘/root/h5check-2.0.1/tool’
Making all in test
make[1]: Entering directory ‘/root/h5check-2.0.1/test’
h5cc ./testgen.c -o testgen
make[1]: h5cc: Command not found
Makefile:586: recipe for target ‘testgen’ failed
make[1]: *** [testgen] Error 127
make[1]: Leaving directory ‘/root/h5check-2.0.1/test’
Makefile:298: recipe for target ‘all-recursive’ failed
make: *** [all-recursive] Error 1

其中有一行說明了一個所需的執行檔h5cc不存在:

make[1]: h5cc: Command not found

因此需要使用以下指令安裝(參考can’t find hdf5.h when build caffe這則issue中loretoparisi的回答)

sudo apt-get -y install libhdf5-10
sudo apt-get -y install libhdf5-serial-dev
sudo apt-get -y install libhdf5-dev
sudo apt-get -y install libhdf5-cpp-11
export CPATH=`find /usr -iname "*hdf5.h*" 2>/dev/null | xargs -I{} dirname {}` 
# 2>/dev/null: 屏蔽錯誤訊息
#  | xargs -I{} dirname {}: 只回傳其目錄
# export CPATH=`<other-command>`: 將其它指令的結果設為環境變量CPATH的值

如果碰到以下問題,請使用相對應指令解決:

  • bash: sudo: command not found

    使用apt-get -y install sudo

  • Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package h5cc

    使用sudo apt-get -y update && apt-get -y upgrade

  • debconf: delaying package configuration, since apt-utils is not installed

    使用sudo apt-get -y install apt-utils

重新執行make指令,出現以下訊息,代表建構成功。

Making all in src
make[1]: Entering directory ‘/root/h5check-2.0.1/src’
make all-am
make[2]: Entering directory ‘/root/h5check-2.0.1/src’
make[2]: Leaving directory ‘/root/h5check-2.0.1/src’
make[1]: Leaving directory ‘/root/h5check-2.0.1/src’
Making all in tool
make[1]: Entering directory ‘/root/h5check-2.0.1/tool’
make[1]: Nothing to be done for ‘all’.
make[1]: Leaving directory ‘/root/h5check-2.0.1/tool’
Making all in test
make[1]: Entering directory ‘/root/h5check-2.0.1/test’
h5cc ./testgen.c -o testgen
make[1]: Leaving directory ‘/root/h5check-2.0.1/test’
make[1]: Entering directory ‘/root/h5check-2.0.1’
make[1]: Nothing to be done for ‘all-am’.
make[1]: Leaving directory ‘/root/h5check-2.0.1’

可以使用make check來檢查建構是否成功,如果成功會出現以下訊息:

Making check in src
make[1]: Entering directory ‘/root/h5check-2.0.1/src’
make check-TESTS
make[2]: Entering directory ‘/root/h5check-2.0.1/src’
make[3]: Entering directory ‘/root/h5check-2.0.1/src’
make[4]: Entering directory ‘/root/h5check-2.0.1/src’
make[4]: Nothing to be done for ‘_exec_check-s’.
make[4]: Leaving directory ‘/root/h5check-2.0.1/src’
make[3]: Leaving directory ‘/root/h5check-2.0.1/src’
make[3]: Entering directory ‘/root/h5check-2.0.1/src’
make[3]: Leaving directory ‘/root/h5check-2.0.1/src’
make[2]: Leaving directory ‘/root/h5check-2.0.1/src’
make[1]: Leaving directory ‘/root/h5check-2.0.1/src’
Making check in tool
make[1]: Entering directory ‘/root/h5check-2.0.1/tool’
make check-TESTS
make[2]: Entering directory ‘/root/h5check-2.0.1/tool’
make[3]: Entering directory ‘/root/h5check-2.0.1/tool’
make[4]: Entering directory ‘/root/h5check-2.0.1/tool’
make[4]: Nothing to be done for ‘_exec_check-s’.
make[4]: Leaving directory ‘/root/h5check-2.0.1/tool’
make[3]: Leaving directory ‘/root/h5check-2.0.1/tool’
make[3]: Entering directory ‘/root/h5check-2.0.1/tool’
make[3]: Leaving directory ‘/root/h5check-2.0.1/tool’
make[2]: Leaving directory ‘/root/h5check-2.0.1/tool’
make[1]: Leaving directory ‘/root/h5check-2.0.1/tool’
Making check in test
make[1]: Entering directory ‘/root/h5check-2.0.1/test’
make testgen ./testh5check.sh
make[2]: Entering directory ‘/root/h5check-2.0.1/test’
make[2]: ‘testgen’ is up to date.
make[2]: Nothing to be done for ‘testh5check.sh’.
make[2]: Leaving directory ‘/root/h5check-2.0.1/test’
make check-TESTS
make[2]: Entering directory ‘/root/h5check-2.0.1/test’
make[3]: Entering directory ‘/root/h5check-2.0.1/test’
=Serial tests in test begin Fri Nov 9 06:23:30 UTC 2018=
make[4]: Entering directory ‘/root/h5check-2.0.1/test’
============================
Testing testgen
Finished testing testgen
============================
testgen Test Log
============================
Generating test files for H5check…
Create root.h5: just the root group
Create linear.h5: a linear group structure
Create hierarchical.h5: a treelike structure
Create multipath.h5: a multipath structure
Create cyclical.h5: a cyclical structure
Create rank_dsets_empty.h5: an empty dataset for each possible rank
Create rank_dsets_full.h5: a full dataset for each possible rank
Create group_dsets.h5: a tree like structure where some groups are empty while others contain a dataset
Create basic_types.h5: datasets using different basic datatypes
Create compound.h5: a dataset using a compound datatype
Create vl.h5: a dataset using a VL datatype
Create enum.h5: a dataset using an enumerated datatype
Create refer.h5: a dataset using reference datatype
Create array.h5: an array datatype
Create filters.h5: several datasets using different filters
Create stdio.h5: using stdio file driver
Create split: using split file driver
Create multi: using multi file driver
Create family%05d.h5: using family file driver
Create log.h5: using log file driver
Create attr.h5: several datasets using attributes
Create time.h5: using time datatype
Create external_empty.h5: an external file without data (no raw data files)
Create external_full.h5: an external file with data
Create alternate_sb.h5: non-standard superblock
Create new_grat.h5: 1.8 group/attribute file
Create sohm.h5: 1.8 SOHM file
Create ext_dangle1.h5: Create ext_dangle2.h5: Dangling external links
Create ext_self1.h5: Create ext_self2.h5: Create ext_self3.h5: External link to self
Create ext_mult1.h5: Create ext_mult2.h5: Create ext_mult3.h5: Create ext_mult4.h5: External links across multiple files
Create ext_pingpong1.h5: Create ext_pingpong2.h5: External links that go back and forth between 2 files
Create ext_toomany1.h5: Create ext_toomany2.h5: Files with too many external links to objects
Create ext_links.h5: File with various links
Create invalid_grps.h5: File with invalid version number in link message…
Create invalid_sym.h5: File with invalid symbol table entries…
Test files generation for H5check successful!
Finished testing testgen
============================
============================
Testing testh5check.sh
Finished testing testh5check.sh
============================
testh5check.sh Test Log
============================
========================================
The following tests are expected to pass.
========================================
Testing h5check basic_types.h5 PASSED
Testing h5check alternate_sb.h5 PASSED
Testing h5check array.h5 PASSED
Testing h5check attr.h5 PASSED
Testing h5check basic_types.h5 PASSED
Testing h5check compound.h5 PASSED
Testing h5check cyclical.h5 PASSED
Testing h5check enum.h5 PASSED
Testing h5check external_empty.h5 PASSED
Testing h5check external_full.h5 PASSED
Testing h5check filters.h5 PASSED
Testing h5check group_dsets.h5 PASSED
Testing h5check hierarchical.h5 PASSED
Testing h5check linear.h5 PASSED
Testing h5check log.h5 PASSED
Testing h5check multipath.h5 PASSED
Testing h5check rank_dsets_empty.h5 PASSED
Testing h5check rank_dsets_full.h5 PASSED
Testing h5check refer.h5 PASSED
Testing h5check root.h5 PASSED
Testing h5check stdio.h5 PASSED
Testing h5check time.h5 PASSED
Testing h5check vl.h5 PASSED
Testing h5check new_grat.h5 PASSED
Testing h5check sohm.h5 PASSED
Testing h5check --exte ext_dangle1.h5 PASSED
Testing h5check -e ext_dangle2.h5 PASSED
Testing h5check --exter ext_self1.h5 PASSED
Testing h5check -e ext_self2.h5 PASSED
Testing h5check --ex ext_self3.h5 PASSED
Testing h5check -e ext_mult1.h5 PASSED
Testing h5check -e ext_mult2.h5 PASSED
Testing h5check -e ext_mult3.h5 PASSED
Testing h5check -e ./ext_mult3.h5 PASSED
Testing h5check -e ext_mult4.h5 PASSED
Testing h5check -e ext_pingpong1.h5 PASSED
Testing h5check -e ext_pingpong2.h5 PASSED
Testing h5check -e ./ext_pingpong2.h5 PASSED
Testing h5check --external ext_toomany1.h5 PASSED
Testing h5check --external ext_toomany2.h5 PASSED
Testing h5check --external ./ext_toomany2.h5 PASSED
Testing h5check -e ext_links.h5 PASSED
========================================
The following tests are expected to fail.
========================================
Testing h5check ./invalidfiles/base_addr.h5 PASSED
Testing h5check ./invalidfiles/offsets_lengths.h5 PASSED
Testing h5check ./invalidfiles/sb_version.h5 PASSED
Testing h5check ./invalidfiles/signature.h5 PASSED
Testing h5check ./invalidfiles/invalid_sym.h5 PASSED
Testing h5check ./invalidfiles/invalid_grps.h5 PASSED
Testing h5check ./invalidfiles/ahmcoef_aix.nc PASSED
Testing h5check ./invalidfiles/corruptfile.h5 PASSED
Testing h5check --format=16 ./invalidfiles/vms_data.h5 PASSED
All h5check tests passed.
Finished testing testh5check.sh
============================
============================
make[4]: Leaving directory ‘/root/h5check-2.0.1/test’
Serial tests in test ended Fri Nov 9 06:23:32 UTC 2018=
make[3]: Leaving directory ‘/root/h5check-2.0.1/test’
make[3]: Entering directory ‘/root/h5check-2.0.1/test’
make[3]: Leaving directory ‘/root/h5check-2.0.1/test’
make[2]: Leaving directory ‘/root/h5check-2.0.1/test’
make[1]: Leaving directory ‘/root/h5check-2.0.1/test’
make[1]: Entering directory ‘/root/h5check-2.0.1’
make[1]: Nothing to be done for ‘check-am’.
make[1]: Leaving directory ‘/root/h5check-2.0.1’

安裝

最後使用make install來安裝,成功後會出現以下訊息:

Making install in src
make[1]: Entering directory ‘/root/h5check-2.0.1/src’
make[2]: Entering directory ‘/root/h5check-2.0.1/src’
make[2]: Nothing to be done for ‘install-exec-am’.
make[2]: Nothing to be done for ‘install-data-am’.
make[2]: Leaving directory ‘/root/h5check-2.0.1/src’
make[1]: Leaving directory ‘/root/h5check-2.0.1/src’
Making install in tool
make[1]: Entering directory ‘/root/h5check-2.0.1/tool’
make[2]: Entering directory ‘/root/h5check-2.0.1/tool’
test -z “/root/h5check-2.0.1/h5check/bin” || /bin/mkdir -p “/root/h5check-2.0.1/h5check/bin”
/usr/bin/install -c h5check ‘/root/h5check-2.0.1/h5check/bin’
make[2]: Nothing to be done for ‘install-data-am’.
make[2]: Leaving directory ‘/root/h5check-2.0.1/tool’
make[1]: Leaving directory ‘/root/h5check-2.0.1/tool’
Making install in test
make[1]: Entering directory ‘/root/h5check-2.0.1/test’
make[2]: Entering directory ‘/root/h5check-2.0.1/test’
test -z “/root/h5check-2.0.1/h5check/bin” || /bin/mkdir -p “/root/h5check-2.0.1/h5check/bin”
make[2]: Nothing to be done for ‘install-data-am’.
make[2]: Leaving directory ‘/root/h5check-2.0.1/test’
make[1]: Leaving directory ‘/root/h5check-2.0.1/test’
make[1]: Entering directory ‘/root/h5check-2.0.1’
make[2]: Entering directory ‘/root/h5check-2.0.1’
make[2]: Nothing to be done for ‘install-exec-am’.
make[2]: Nothing to be done for ‘install-data-am’.
make[2]: Leaving directory ‘/root/h5check-2.0.1’
make[1]: Leaving directory ‘/root/h5check-2.0.1’

測試

但是這時使用h5check這個指令卻還是會出現以下錯誤:

bash: h5check: command not found

這是怎麼回事呢?
我們使用find . -name h5check來查看是否存在這份檔案:

./tool/h5check
./h5check
./h5check/bin/h5check

可以發現h5check的執行檔存在於./h5check/bin這個資料夾下。
使用以下指令將該目錄加入環境變量PATH中:

cd h5check/bin
export PATH=$PATH:`pwd`

接著回到安裝目錄下測試:

cd ../..
h5check test/mult4.h5

便會看到以下訊息:

VALIDATING test/ext_mult4.h5 according to library version 1.8.0
No non-compliance errors found

代表h5check現在己可以正常運作。

參考連結

猜你喜欢

转载自blog.csdn.net/keineahnung2345/article/details/83896585