【问题标题】:Open an HDF5 file error打开 HDF5 文件错误
【发布时间】:2011-10-19 15:13:22
【问题描述】:

我创建了一个 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:无法解析的外部符号“公共:静态类 H5::FileCreatPropList const H5::FileCreatPropList::DEFAULT”(?DEFAULT@FileCreatPropList@H5@@2V12@B)
TwinSatObservation.obj:错误 LNK2001:未解析的外部符号“公共:静态类 H5::FileAccPropList const H5::FileAccPropList::DEFAULT”(?DEFAULT@FileAccPropList@H5@@2V12@B)
F:\Tips\Debug\Tips.exe : 致命错误 LNK1120: 2 unresolved externals

我将以下库添加到 VS 2008 链接器的“附加依赖项”输入框中
hdf5dll.lib
hdf5_hldll.lib
hdf5_cppdll.lib
hdf5_hl_cppdll.lib

您能告诉我我忘记添加哪个库吗?非常感谢!

【问题讨论】:

    标签: c++ hdf5


    【解决方案1】:

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

    【讨论】:

    • 预处理器定义输入框在哪里?在链接器-> 输入中?我正在使用 VS 2015,找不到这个!
    【解决方案2】:

    对于带有 VS2010 或 VS2015 的 hdf5-1.8.17,将 H5_BUILT_AS_DYNAMIC_LIB 定义为预处理器设置(Project > Properties > C/C++ > Preprocessor > Preprocessor Definitions)可以治愈完全相同的症状为了我。感谢original post

    【讨论】:

      猜你喜欢
      • 2020-03-11
      • 2017-07-01
      • 2015-10-10
      • 2017-03-19
      • 2023-04-06
      • 1970-01-01
      • 2011-12-02
      • 1970-01-01
      • 2015-08-22
      相关资源
      最近更新 更多