在Visual Studio中链接DLL [英] Linking dll in Visual Studio
问题描述
如何在Visual Studio 2010中添加.dll
?我只是在那里找不到选项.
How can I add a .dll
in Visual Studio 2010? I just cannot find the option there.
推荐答案
在Windows上,您不直接链接.dll
文件–您必须改为使用随附的.lib
文件.为此,请转到Project -> Properties -> Configuration Properties -> Linker -> Additional Dependencies
并在下一行将路径添加到您的.lib.
On Windows you do not link with a .dll
file directly – you must use the accompanying .lib
file instead. To do that go to Project -> Properties -> Configuration Properties -> Linker -> Additional Dependencies
and add path to your .lib as a next line.
您还必须确保.dll
文件位于%PATH%
环境变量包含的目录中,或者其副本位于Output Directory
中(默认情况下,此Debug\Release
在您项目的文件夹下).
You also must make sure that the .dll
file is either in the directory contained by the %PATH%
environment variable or that its copy is in Output Directory
(by default, this is Debug\Release
under your project's folder).
如果您无权访问.lib
文件,另一种方法是在运行时使用WINAPI函数(例如GetProcAddress .
If you don't have access to the .lib
file, one alternative is to load the .dll
manually during runtime using WINAPI functions such as LoadLibrary and GetProcAddress.
这篇关于在Visual Studio中链接DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!