Static lib vs DLL in visual studio

六月ゝ 毕业季﹏ 提交于 2020-06-16 11:31:28

问题


I have built VTK in my computer with both dll and .lib files. When I want to create a project that uses VTK, I have to include the header files and link .lib files in project properties. In addition I have to add the .dll files in to the project path as well. I have several questions regarding this,

  1. What is the difference between .libs and .dll files?
  2. Is it possible to create a project with only using either .dll or .lib files. (I can link the .lib files and not add dlls to path or add dlls to path and not link .lib files)?

I would be grateful for any explanations. Thanks.


回答1:


  1. .lib files are used by the linker to resolve imported items. .dll files contain code that is loaded dynamically at runtime.

  2. If you have a static library, it contains all the code needed and there is no .dll. If you have a .dll you also need the companion .lib for linking correctly.




回答2:


The .lib files are only used by the linker during compilation. Whereas .dll files are used by the compiled exe during execution. In other words, after you've compiled the program you shouldn't need the .lib files anymore. When packaging your software for distribution you will only need your .exe, the .dll's, and any resources that didn't get packaged into your exe.



来源:https://stackoverflow.com/questions/34390997/static-lib-vs-dll-in-visual-studio

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