如何在 Windows 10 Visual Studio 中使用所需的“.dll"进行构建 [英] How to build with required `.dll` in Windows 10 Visual Studio

查看:24
本文介绍了如何在 Windows 10 Visual Studio 中使用所需的“.dll"进行构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个项目.我有需要在我的项目中使用的 a.lib 文件.我知道有两种方法可以使用这个库:

I'm trying to build a project. I have a.lib file that I need to use in my project. I know that there are two ways to use this lib:

  • 使用 #pragma comment(lib, "a.lib")
  • 添加它
  • 将其添加到链接器依赖项 Configuration Properties ->链接器 ->输入 ->额外的依赖

现在,a.lib 使用 StackWalk64 函数 DbgHelp.该库以 DbgHelp.libDbgHelp.dll 的形式提供.我知道我可以使用上面列出的两种方式将它用作 lib .但是,如果我不想将它包含到我的项目中并想使用 DbgHelp.dll,我该如何在 Visual Studio 中做到这一点?

Now, a.lib uses StackWalk64 function DbgHelp. This library is supplied as DbgHelp.lib and DbgHelp.dll. I know that I can use it as a lib using two ways listed above. But what if I don't want to include it into my project and want to use DbgHelp.dll, how can I do that in Visual Studio?

推荐答案

请阅读:http://www.learncpp.com/cpp-tutorial/a1-static-and-dynamic-libraries/

在这种情况下,静态库是一个导入库",它使确定 DLL 中有效函数的过程自动化.这称为隐式动态链接.

In this case the static-library is an "import library", which automates the process of determining the effective functions in the DLL. This is called implicit dynamic linkage.

如果你不想使用导入库,你必须自己确定所有函数,创建相应的指向过程地址的指针,然后使用它们.通常在您的客户端代码中有一些 InitDLL() 函数,它可以执行此操作.

If you don't want to use the import library you have to determine all functions by yourself, create corresponding pointers to the addresses of the procedures and use them after that. Usually there's some InitDLL() function in your client code, which does this.

请参阅:https://msdn.microsoft.com/de-de/library/64tkc9y5.aspx

GetProcAddress"函数可用于获取该函数的句柄并调用它.

The "GetProcAddress"-function can be used to obtain a handle to the function and call it.

这称为显式动态链接,并且还需要在 Windows 上调用 LoadLibrary() 和 FreeLibrary().

This is called explicit dynamic linkage and requires also the calls to LoadLibrary() and FreeLibrary() on Windows.

更多信息:http://www.questionanswers.com/dll/what-is-implicit-and-explicit-linking-in-dynamic-loading.php

对于 linux/unix,工作方式不同.如果你想阅读:http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html

For linux/unix things work differently. If you want to read up: http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html

这篇关于如何在 Windows 10 Visual Studio 中使用所需的“.dll"进行构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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