Visual Studio中的静态库与DLL [英] Static lib vs DLL in visual studio

查看:292
本文介绍了Visual Studio中的静态库与DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的计算机中同时使用dll和.lib文件构建了 VTK 。当我要创建使用VTK的项目时,必须在项目属性中包含头文件和链接.lib文件。另外,我还必须将.dll文件添加到项目路径中。我对此有几个疑问,

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. .libs和.dll文件有什么区别?

  2. 是否可以仅使用.dll或.lib文件来创建项目。 (我可以链接.lib文件,而不将dll添加到路径,或者将dlls添加到路径,而不链接.lib文件)?

我将不胜感激。谢谢。

推荐答案


  1. .lib文件由链接器用来解析导入的项目。 .dll文件包含在运行时动态加载的代码。

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

如果您有静态库,它将包含所有需要的代码,并且没有.dll。如果您有.dll,则还需要随附的.lib才能正确链接。

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.

这篇关于Visual Studio中的静态库与DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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