我正在嘗試使用執行基本的 C 腳本(此處)。我相信我已經使用以下方法正確安裝了 HDF5 庫:
sudo apt install libhdf5-dev
當我第一次嘗試使用以下代碼編譯代碼時:
g hdf5_simple.cpp -lhdf5 -lhdf5_cpp -o hdf5_simple
我有:
hdf5_simple.cpp:3:10: fatal error: H5Cpp.h: No such file or directory
很簡單,我嘗試:
g -I/usr/include/hdf5/serial/ hdf5_simple.cpp -lhdf5 -lhdf5_cpp -o hdf5_simple
它沒有任何問題,但是當我嘗試運行它時得到:
The HDF5 header files used to compile this application do not match
the version used by the HDF5 library to which this application is linked.
Data corruption or segmentation faults may occur if the application continues.
This can happen when an application was compiled by one version of HDF5 but
linked with a different version of static or shared HDF5 library.
You should recompile the application or check your shared library related
settings such as 'LD_LIBRARY_PATH'.
You can, at your own risk, disable this warning by setting the environment
variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.
Setting it to 2 or higher will suppress the warning messages totally.
Headers are 1.10.4, library is 1.13.0
SUMMARY OF THE HDF5 CONFIGURATION
=================================
General Information:
-------------------
HDF5 Version: 1.13.0
Configured on: Wed Dec 22 18:04:31 UTC 2021
Configured by: ***@***
Host system: x86_64-unknown-linux-gnu
Uname information: Linux *** 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Byte sex: little-endian
Installation point: /usr/local/hdf5
Compiling Options:
------------------
Build Mode: production
Debugging Symbols: no
Asserts: no
Profiling: no
Optimization Level: high
Linking Options:
----------------
Libraries: static, shared
Statically Linked Executables:
LDFLAGS:
H5_LDFLAGS:
AM_LDFLAGS:
Extra libraries: -lz -ldl -lm
Archiver: ar
AR_FLAGS: cr
Ranlib: ranlib
Languages:
----------
C: yes
C Compiler: /usr/bin/mpicc ( MPICH version 3.3.2 Configured with: ../src/configure -v --with-pkgversion='Ubuntu 8.4.0-3ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c ,go,brig,d,fortran,objc,obj-c --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu built with gcc version 8.4.0 (Ubuntu 8.4.0-3ubuntu2))
CPPFLAGS:
H5_CPPFLAGS: -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L -DNDEBUG -UH5_DEBUG_API
AM_CPPFLAGS:
C Flags:
H5 C Flags: -std=c99 -Wall -Wcast-qual -Wconversion -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Winvalid-pch -Wmissing-include-dirs -Wno-c -compat -Wno-format-nonliteral -Wshadow -Wundef -Wwrite-strings -pedantic -Wlarger-than=2560 -Wlogical-op -Wframe-larger-than=16384 -Wpacked-bitfield-compat -Wsync-nand -Wstrict-overflow=5 -Wno-unsuffixed-float-constants -Wdouble-promotion -Wtrampolines -Wstack-usage=8192 -Wmaybe-uninitialized -Wdate-time -Warray-bounds=2 -Wc99-c11-compat -Wduplicated-cond -Whsa -Wnormalized -Wnull-dereference -Wunused-const-variable -Walloca -Walloc-zero -Wduplicated-branches -Wformat-overflow=2 -Wformat-truncation=1 -Wrestrict -Wattribute-alias -Wcast-align=strict -Wshift-overflow=2 -fstdarg-opt -s -Wbad-function-cast -Wimplicit-function-declaration -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpacked -Wpointer-sign -Wpointer-to-int-cast -Wint-to-pointer-cast -Wredundant-decls -Wstrict-prototypes -Wswitch -Wunused-function -Wunused-variable -Wunused-parameter -Wcast-align -Wunused-but-set-variable -Wformat -Wincompatible-pointer-types -Wint-conversion -Wshadow -Wcast-function-type -Wmaybe-uninitialized -Wno-aggregate-return -Wno-inline -Wno-missing-format-attribute -Wno-missing-noreturn -Wno-overlength-strings -Wno-jump-misses-init -Wno-suggest-attribute=const -Wno-suggest-attribute=noreturn -Wno-suggest-attribute=pure -Wno-suggest-attribute=format -Wno-suggest-attribute=cold -Wno-suggest-attribute=malloc -O3
AM C Flags:
Shared C Library: yes
Static C Library: yes
Fortran: no
C : no
Java: no
Features:
---------
Parallel HDF5: yes
Parallel Filtered Dataset Writes: yes
Large Parallel I/O: yes
High-level library: yes
Dimension scales w/ new references: no
Build HDF5 Tests: yes
Build HDF5 Tools: yes
Threadsafety: no
Default API mapping: v114
With deprecated public symbols: yes
I/O filters (external): deflate(zlib)
MPE:
Map (H5M) API: no
Direct VFD: no
Mirror VFD: no
(Read-Only) S3 VFD: no
(Read-Only) HDFS VFD: no
dmalloc: no
Packages w/ extra debug output: none
API tracing: no
Using memory checker: no
Memory allocation sanity checks: no
Function stack tracing: no
Use file locking: best-effort
Strict file format checks: no
Optimization instrumentation: no
Bye...
Aborted (core dumped)
按照警告頂部的注釋,我添加#define DF5_DISABLE_VERSION_CHECK 1并重新編譯并出現相同的警告。然后我嘗試使用添加到 LD_LIBRARY_PATH 的路徑,export LD_LIBRARY_PATH="/usr/include/hdf5/serial/"但仍然沒有運氣。
我不確定出了什么問題。任何幫助將不勝感激。
uj5u.com熱心網友回復:
試試這個:
g `pkg-config --cflags hdf5-serial` hdf5_simple.cpp `pkg-config --libs hdf5-serial` -lhdf5_cpp -o hdf5_simple
該命令將允許您針對 C 單執行緒版本構建程式。
由于將 hdf5 移植到 Node.js(我是 Node.js 的作者gdal-async),我可以證明它有一些可怕的怪癖:它有兩個非常重要的編譯選項,執行緒安全選項和 C API。這兩者不兼容,并且當兩者都啟用時,庫存 tarball 將拒絕構建。Debian/Ubuntu 團隊竭盡全力允許您同時使用它們——只要不是同時使用——它要么是 C (他們稱之為高級 API),要么是多執行緒。
好像這還不夠,正如我從您的配置中看到的那樣,您似乎還混合了啟用 MPI 的版本。
不要禁用任何警告和檢查,并且要非常小心鏈接程式的內容,否則您將在運行時遇到一些非常令人討厭的意外。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/414832.html
標籤:
