打开一个HDF5文件时出现错误。

7
我创建了一个如下所示的HDF5文件打开功能:
```python def open_hdf5_file(file_path): with h5py.File(file_path, "r") as f: return f ```
这个函数可以用于打开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:static class H5 :: FileCreatPropList const H5 :: FileCreatPropList :: DEFAULT"(?DEFAULT@FileCreatPropList@H5@@2V12@B)
TwinSatObservation.obj:错误LNK2001:未解析的外部符号"public:static class H5 :: FileAccPropList const H5 :: FileAccPropList :: DEFAULT"(?DEFAULT@FileAccPropList@H5@@2V12@B)
F:\Tips\Debug\Tips.exe:致命错误LNK1120:2个未解决的外部
我将以下库添加到VS 2008链接器的“附加依赖项”输入框中:
hdf5dll.lib
hdf5_hldll.lib
hdf5_cppdll.lib
hdf5_hl_cppdll.lib
请问我忘记了哪个库?非常感谢!
2个回答

9

对于使用VS2010或VS2015编译的hdf5-1.8.17,将H5_BUILT_AS_DYNAMIC_LIB定义为预处理器设置(项目 > 属性 > C/C++ > 预处理器 > 预处理器定义),可以治疗我遇到的完全相同的症状。感谢原帖


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

预处理器定义输入框在哪里?是在链接器->输入中吗?我正在使用VS 2015,但找不到它! - sorry_I_wont

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接