linker - 找不到符号 - 链接到 hdf 库

标签 linker hdf

我正在尝试使用 hdf5 格式来存储数据。问题是,我无法链接到图书馆。我有以下代码

#include <H5Cpp.h>
int main(void){
    H5::H5File file("test_MatrixRoundTrip_Double.h5", H5F_ACC_TRUNC);
}

并使用

编译它
gcc -std=c++11 -o main main.cpp -I /usr/local/include/ -L /usr/local/lib/ -lhdf5 -lhdf5_hl

这总是返回错误

Undefined symbols for architecture x86_64:
  "H5::FileAccPropList::DEFAULT", referenced from:
  _main in main-c207d1.o
  "H5::FileCreatPropList::DEFAULT", referenced from:
  _main in main-c207d1.o
  "H5::H5File::H5File(char const*, unsigned int, H5::FileCreatPropList const&, H5::FileAccPropList const&)", referenced from:
  _main in main-c207d1.o
  "H5::H5File::~H5File()", referenced from:
  _main in main-c207d1.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我使用

在 OSX 上安装了 hdf5 库
brew install homebrew/science/hdf5

我在这里做错了什么?

最佳答案

您包含 HDF5 C++ 头文件,但仅链接 HDF5 C 库。添加行:-lhdf5_cpp 以链接 C++ 共享对象并使用 locate libhdf5_cpp 找到它的 libpath。

关于linker - 找不到符号 - 链接到 hdf 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34050155/

相关文章:

c - 使用数据类型检测从 HDF5 文件中的数据集中读取

python - 写入 HDFStore 时能否保留 Pandas tseries DatetimeIndex 的频率?

azure - Nifi java.lang.NoSuchMethodError : org. apache.hadoop.conf.Configuration.reloadExistingConfigurations

c++ - GCC C++ 链接器错误 : Undefined reference to 'vtable for XXX' , 对 'ClassName::ClassName()' 的 undefined reference

c - 使用链接器命令将 C 中的数组分配到特定位置

链接时可以混合使用静态库和共享对象库吗?

python - Pandas read_hdf 对于非数字数据非常慢

c++ - 对 `FIFORequestChannel::FIFORequestChannel 的 undefined reference

c++ - CUDA 和链接器错误

sql-server - 如何使用 Nifi/HDF 从 MS SQL 读取增量记录