在Visual Studio中链接DLL [英] Linking dll in Visual Studio

查看:151
本文介绍了在Visual Studio中链接DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆