为什么某些程序需要.lib和.dll都起作用... [英] Why some programs require both .lib and .dll to work...

查看:175
本文介绍了为什么某些程序需要.lib和.dll都起作用...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我要为(SDLSimple DirectMediaLayer)设置开发环境时,我从 readme下载了网站提供的软件包。 .txt 文件,我发现我同时需要 .lib .dll ...

When I was going to set up my developing environment for (SDLSimple DirectMediaLayer), I downloaded the package provided by the website, from the readme.txt file I found that I need both .lib and .dll...

我的问题是:


  1. 我不确定我的理解是否正确:在我看来,用于 windows .lib 就像 .a linux ,c>是静态库,对于<$ c $,是 .dll c> windows 就像 .so 对于 linux ,是共享库,这正确吗?

  2. 如果以上想法正确,我认为我们只能使用 .lib .dll ,因为它们所做的工作是相同的?那么为什么要花两个钱在一个程序中?

  3. 我不太理解 .dll ,如果我的内存服务器正确,共享库的优势之一是可以在问题运行时对其进行更新,因此如果我们进行更新,人们将如何做到这一点? .dll 文件,正在运行的程序如何了解 .dll 并将其重新加载到内存中?

  1. I am not sure if my understanding is correct : in my thought, .lib for windows is like .a for linux, is static library, and .dll for windows is like .so for linux, is shared library, is this correct ?
  2. If the idea above is correct, I think we can only use .lib or .dll, since the work they do is the same ? So why bother to get both two in one program ?
  3. And I do not quite understand .dll, if my memory servers me right, the one of the advantage for shared library is they can be updated while the problem is running, so how can people do this, if we update the .dll file, how can an running program get to know the changes of the .dll and reload it to memory ?


推荐答案

在VC中,有两种库。

In VC, there are two kinds of libs.

第一种类型是静态库,由静态库项目生成,其中包含无需dll即可链接和运行的所有内容。

First type is a "real library", generated by the "static library project", which contains everything you can link and run, without dll.

第二种类型是导入库,由 dll项目生成,其中仅包含link.exe需要的符号。您可以链接到库,但是需要运行dll。

The second type is "import library", generated by the "dll project", which just contains the symbols the link.exe needs. You can link to the library, but you need the dll to run.

有两种使用dll的方法。链接到导入库或使用LoadLibrary API。

There are two ways to use a dll. Link to the "import library" or "use LoadLibrary API".

加载dll时无法更改dll文件。

You can not change the dll file when the dll is loaded.

但是如果使用LoadLibrary加载dll,您可以使用FreeLibrary卸载dll,更改dll,然后使用LoadLibrary加载新的dll。当然,您需要监视某些内容才能调用此过程。

But if you use LoadLibrary to load the dll, you can use FreeLibrary to unload the dll, change the dll and then use LoadLibrary to load the new dll. Of course, you need to monitor something to invoke this procedure.

更简单的方法是,使用加载程序进行更新,然后加载真实的exe文件。

Still the easier way is that, use a loader to do the update, then load the real exe.

这篇关于为什么某些程序需要.lib和.dll都起作用...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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