打开 HDF5 文件错误
我创建了一个HDF5文件打开函数,如下所示:
int OpenHDF5(string sFileName)
{
// Check for valid HDF5 file
if (!H5File::isHdf5(sFileName.c_str()))
{
// Invalid HDF5 file
return -1
}
// Try block to detect exceptions raised by any of the calls inside it
try
{
// Turn off the auto-printing when failure occurs so that we can handle the errors appropriately
Exception::dontPrint();
// Now Open the file
H5File file( sFileName.c_str(), H5F_ACC_RDONLY );
}
// Catch failure caused by the H5File operations
catch( FileIException error )
{
error.printError();
return -1
}
return 0
}
没有发生编译错误,但无法链接,出现以下异常: 正在链接...
创建库 F:\Tips\Debug\Tips.lib 和对象 F:\Tips\Debug\Tips.exp
TwinSatObservation.obj:错误 LNK2001:无法解析的外部符号“public:静态类 H5::FileCreatPropList const H5::FileCreatPropList::DEFAULT”(?DEFAULT@FileCreatPropList@H5@@2V12@B)
TwinSatObservation.obj:错误 LNK2001:无法解析的外部符号“public:静态类 H5::FileAccPropList const H5::FileAccPropList::DEFAULT”(?DEFAULT@FileAccPropList@H5@@2V12@B)
F:\Tips\Debug\Tips.exe : fatal error LNK1120: 2 unresolved externals
我将以下库添加到 VS 2008 链接器的“附加依赖项”输入框中
hdf5dll.lib
hdf5_hldll.lib
hdf5_cppdll.lib
hdf5_hl_cppdll.lib
请告诉我我忘记添加哪个库?非常感谢!
I created an HDF5 file open function like the following:
int OpenHDF5(string sFileName)
{
// Check for valid HDF5 file
if (!H5File::isHdf5(sFileName.c_str()))
{
// Invalid HDF5 file
return -1
}
// Try block to detect exceptions raised by any of the calls inside it
try
{
// Turn off the auto-printing when failure occurs so that we can handle the errors appropriately
Exception::dontPrint();
// Now Open the file
H5File file( sFileName.c_str(), H5F_ACC_RDONLY );
}
// Catch failure caused by the H5File operations
catch( FileIException error )
{
error.printError();
return -1
}
return 0
}
No compiling error occurred, but failed to link with the following exceptions:
Linking...
Creating library F:\Tips\Debug\Tips.lib and object F:\Tips\Debug\Tips.exp
TwinSatObservation.obj : error LNK2001: unresolved external symbol "public: static class H5::FileCreatPropList const H5::FileCreatPropList::DEFAULT" (?DEFAULT@FileCreatPropList@H5@@2V12@B)
TwinSatObservation.obj : error LNK2001: unresolved external symbol "public: static class H5::FileAccPropList const H5::FileAccPropList::DEFAULT" (?DEFAULT@FileAccPropList@H5@@2V12@B)
F:\Tips\Debug\Tips.exe : fatal error LNK1120: 2 unresolved externals
I added the following libraries to "Addtional Dependencies" input box of the VS 2008 Linker
hdf5dll.lib
hdf5_hldll.lib
hdf5_cppdll.lib
hdf5_hl_cppdll.lib
Would you please tell me which library I forgot to add? Thank you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于使用 VS2010 或 VS2015 的 hdf5-1.8.17,将
H5_BUILT_AS_DYNAMIC_LIB
定义为预处理器设置(Project > Properties > C/C++ > Preprocessor > Preprocessor Definitions )为我治愈了完全相同的症状。感谢原始帖子。As for hdf5-1.8.17 with either VS2010 or VS2015, defining
H5_BUILT_AS_DYNAMIC_LIB
as a preprocessor setting (Project > Properties > C/C++ > Preprocessor > Preprocessor Definitions) cures exactly the same symptom for me. Thanks to the original post.在预处理器定义输入框中添加
HDF5CPP_USEDLL;_HDF5USEDLL_;
。Add
HDF5CPP_USEDLL;_HDF5USEDLL_;
in Preprocessor Definitions input box.