Why some programs require both .lib and .dll to work…

半世苍凉 提交于 2019-12-10 23:30:05

问题


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...

My question is :

  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 ?

回答1:


In VC, there are two kinds of libs.

First type is a "real library", generated by the "static library project", which contains everything you can link and run, without 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.

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

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

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.

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



来源:https://stackoverflow.com/questions/38602618/why-some-programs-require-both-lib-and-dll-to-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!