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

查看:67
本文介绍了为什么某些程序需要.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 是静态库,用于 windows .dll 类似于用于 .so .so > linux 是共享库,这是正确的吗?
  2. 如果上述想法正确,我认为我们只能使用 .lib .dll ,因为它们所做的工作是相同的吗?那么,为什么要麻烦两个人同时在一个程序中加入?
  3. 我不太理解 .dll ,如果我的内存服务器正确,则 shared library 的优点之一是可以在程序运行时对其进行更新正在运行,那么人们如何做到这一点,如果我们更新 .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 program 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中,有两种库.

第一种类型是由静态库项目"生成的真实库",其中包含您可以链接和运行的所有内容,而无需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天全站免登陆