将HDF5库链接到Visual C ++ DLL项目:未解析的外部符号__imp __ * [英] Linking HDF5 library into Visual C++ DLL project: unresolved external symbol __imp__*
问题描述
我正在使用MS Visual C ++ 2010 Express构建插件,我想包括 HDF5库.我已经尝试使用CMake从源代码构建HDF5,并安装了预编译的库( HDF5-1.8.7_CMake_x86_shared.zip
(对于VC 2008).对于任一构建目录/方法,我都修改了项目属性:
I'm building a plug-in with MS Visual C++ 2010 Express, and I would like to include capabilities from the HDF5 library. I have tried both building HDF5 from source with CMake, and installing the precompiled library (HDF5-1.8.7_CMake_x86_shared.zip
for VC 2008). For either build directory/method, I've modified my project property:
- C/C ++>常规>其他包含目录:为HDF5添加
include
- 链接器>常规>其他库目录:为HDF5添加
lib
- C/C++ > General > Additional Include Directories: add the
include
for HDF5 - Linker > General > Additional Library Directories: add the
lib
for HDF5
这是我的DLL模块的摘要:
Here is a snippet of my DLL module:
#include "cpp/H5Cpp.h"
static IResult OnBeginDocument (IDocument pDoc)
{
H5Fcreate("C:\\out.h5", H5F_ACC_EXCL, H5P_DEFAULT, H5P_DEFAULT);
return True;
}
请注意,当我将鼠标悬停在该代码段上时,VC ++可以正确地解析.h
文件,例如,直观地显示H5Fcreate
的弹出式文档.我的问题是我无法构建尝试使用H5Fcreate
的模块.这是我的构建尝试中的控制台输出:
Note that VC++ correctly parses the .h
files to, e.g., visually show pop-up documentation for H5Fcreate
when I hover my mouse over that snippet. My problem is that I cannot build the module that tries to use H5Fcreate
. Here is the console output from my build attempts:
1>MyProject.obj : error LNK2019: unresolved external symbol __imp__H5Fcreate referenced in function "int __cdecl OnBeginDocument(struct IModuleStruct *)" (?OnBeginDocument@@YAHPAUIModuleStruct@@@Z)
1>MyProject.obj : error LNK2019: unresolved external symbol __imp__H5check_version referenced in function "int __cdecl OnBeginDocument(struct IModuleStruct *)" (?OnBeginDocument@@YAHPAUIModuleStruct@@@Z)
1>C:\MyProject\Release\MyProject.dll : fatal error LNK1120: 2 unresolved externals
尝试链接HDF5的两种方法(如上所述,预编译与自编译)都会产生这些完全相同的错误,因此我不确定我要去哪里.
Both methods of attempting to link in HDF5 (precompiled vs self-compiled, as described above) produce these exact same errors, so I'm not sure where I'm going wrong.
非常感谢@HasanKhan和@StevieG,这些都是对像我这样的n00b有用的提示.为了清楚起见,我确实确实需要在链接器>输入>其他依赖项中添加lib文件路径:
Many thanks to @HasanKhan and @StevieG, these were helpful tips for n00bs like me. Just to follow up clearly, I did indeed need to add lib filepaths in Linker > Input > Additional Dependencies:
hdf5dll.lib
hdf5_cppdll.lib
如果我需要其他HDF5功能,则可能需要添加其他lib文件.另外,事实证明,我需要将HDF5 DLL(从bin
)复制到我的系统目录(例如,C:\WINDOWS\System32\
)中,以使插件在运行时正确运行.现在一切都很好,谢谢!
I may need to add other lib files if I require other HDF5 features. Also, it turned out that I needed to copy the HDF5 DLLs (from bin
) into my system directory (e.g., C:\WINDOWS\System32\
) for the plugin to operate correctly at runtime. All good now, thanks!
推荐答案
-
链接器>常规>其他库目录:您应添加
Linker > General > Additional Library Directories: you should add the path to the directory containing the .lib file here
链接器>常规>输入:您应在此处添加.lib文件的名称
Linker > General > Input: you should add the name of the .lib file here
这篇关于将HDF5库链接到Visual C ++ DLL项目:未解析的外部符号__imp __ *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!