我試着寫一個非常短的腳本來打開一個hdf5文件,但它不起作用。HDF5 - C++ - 打開文件讀取內容失敗
#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建設。我如何在這裏做到這一點? – smaica
啊,我發現了!屬性 - C/C++構建 - 設置 - 鏈接器庫謝謝!有效 – smaica