如何.h,.lib& .dll一起工作 [英] How does .h, .lib & .dll works together

查看:95
本文介绍了如何.h,.lib& .dll一起工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要使用FreeGlut库函数,必须执行以下操作:

To use FreeGlut librarie function, I had to do the following,


  • 将freeglut.h添加为标题文件

  • 将freeGlut.lib添加为资源文件

  • 将freeGlut.dll复制到我的Windows / SysWOW64文件夹

但是,整个系统(.h,.lib& .dll)是如何相互关联的?

But, how this whole system(.h, .lib & .dll) is interrelated with each other?

最基本的事情是添加一个带类声明的头文件,并在其各自的源文件上写入正文。最后包括头文件到你的主应用程序。

I know, the most basic thing is add a header file with class declaration and write the body on its respective source file. Finally include the header file to you main app.

推荐答案

你必须包括头文件,以便编译器理解声明

You have to include the header files so that the compiler understands the declarations of various types and functions that are exposed/used by the library.

库文件(lib或dll)包含使用库链接到的代码。

The library files(lib or dll) contain the object code to which the code using the library links to.

对于lib,链接是静态的,并且在编译时发生。使用静态库(lib)会导致可执行文件的大小增加,因为整个lib链接到你的程序。

for lib the linkage is static and happens at compile time.Using a static library(lib) causes the size of your executable to increase because the entire lib is linked in to your program.

对于dll,链接是动态的,调用是在运行时评估的。使用dll时,可执行文件的大小不会增加,因为dll在运行时链接,您通常需要将它们放置在预定义的路径,以便它们可以在运行时链接。

for dll the linkage is dynamic and calls are evaluated at runtime.When using dll the size of your executable does not increase because the dll's are linked at runtime and you usually need to place them at predefined paths so that they can be linked at runtime.

静态库优于DLL是您的可执行文件使用lib是独立的在dll的情况下,dll需要存在于一个预定义的路径,它运行使用它的可执行文件。

Advantage of static library over dll is that your executable which uses the lib is standalone while in case of dll, the dll needs to be present at a predefined path whil running the executable which uses it.

这篇关于如何.h,.lib& .dll一起工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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