【发布时间】:2014-05-05 01:40:21
【问题描述】:
我尝试编写一个非常短的脚本来打开一个 hdf5 文件,但它不起作用。
#include <iostream>
#include "H5Cpp.h"
#ifndef H5_NO_NAMESPACE
using namespace H5;
#endif
const H5std_string FILE_NAME( "testfile.h5" );
int main (void)
{
H5File openFile( FILE_NAME, H5F_ACC_RDONLY );
}
我很确定我包含了 hdf5 库和包含的路径。 但尽管如此,我还是从链接器收到了错误消息:
Invoking: GCC C++ Linker
g++ -L/usr/local/pub/lib64 -L/usr/local/pub/lib -L/lib64 -L/usr/lib64 -o "HDF5_CPP" ./openfile.o
./openfile.o: In function `main':
/athome/augs_ay/workspace/HDF5_CPP/Debug/../openfile.cpp:18: undefined reference to `H5check_version'
/athome/augs_ay/workspace/HDF5_CPP/Debug/../openfile.cpp:18: undefined reference to `H5::FileAccPropList::DEFAULT'
/athome/augs_ay/workspace/HDF5_CPP/Debug/../openfile.cpp:18: undefined reference to `H5::FileCreatPropList::DEFAULT'
/athome/augs_ay/workspace/HDF5_CPP/Debug/../openfile.cpp:18: undefined reference to `H5::H5File::H5File(std::string const&, unsigned int, H5::FileCreatPropList const&, H5::FileAccPropList const&)'
/athome/augs_ay/workspace/HDF5_CPP/Debug/../openfile.cpp:18: undefined reference to `H5::H5File::~H5File()'
collect2: error: ld returned 1 exit status
make: *** [HDF5_CPP] Error 1
谁能帮忙? 谢谢!
【问题讨论】:
-
您需要将
-lhdf5_cpp -lhdf5添加到您的构建命令中。 -
我正在使用 Eclipse 进行构建。我该怎么做?
-
啊,我找到了!属性 - C/C++ 构建 - 设置 - 链接器库 谢谢!成功了
标签: c++ linker-errors hdf5