6

我创建了一个 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
}           

未发生编译错误,但无法链接,出现以下异常: Linking...
Creating library F:\Tips\Debug\Tips.lib and object F:\Tips\Debug\Tips.exp
TwinSatObservation.obj : error LNK2001: unresolved外部符号“公共:静态类 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 个未解决的外部

我将以下库添加到 VS 2008 Linker
hdf5dll.lib
hdf5_hldll.lib
hdf5_cppdll.lib
hdf5_hl_cppdll.lib的“Addtional Dependencies”输入框中

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

4

2 回答 2

7

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

于 2016-11-14T05:58:26.263 回答
2

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

于 2011-08-04T10:11:05.437 回答