打开 HDF5 文件错误

发布于 2024-11-28 02:11:08 字数 1381 浏览 5 评论 0原文

我创建了一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浊酒尽余欢 2024-12-05 02:11:08

对于使用 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.

骄傲 2024-12-05 02:11:08

预处理器定义输入框中添加HDF5CPP_USEDLL;_HDF5USEDLL_;

Add HDF5CPP_USEDLL;_HDF5USEDLL_; in Preprocessor Definitions input box.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文