在比较 Windows、控制台、静态库和 C 语言中的 DLL 时,后两者有何用途?

发布于 2024-11-09 11:38:54 字数 42 浏览 0 评论 0原文

我很难理解我的文字,我想非常了解每个部分。请尽可能进行描述。非常感谢。

I'm having difficult understanding my text, and I want to know each section extremely well. Please, be as descriptive as possible. Thank you, very much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

顾挽 2024-11-16 11:38:54

程序员经常发现他们有一些想要在多个程序中使用的代码,或者他们想要允许其他程序员使用的代码。他们可以将逻辑复制并粘贴到每个程序中,或者可以将逻辑放置在每个项目中包含的公共头文件和实现文件中。这两种方法都不是非常优雅(或高效)。

静态库是共享逻辑的一种方式,以便其他程序和程序员可以使用它。静态库是适合输入到链接器的二进制文件(通常带有 .LIB 扩展名)。程序员通过编写代码来调用静态库中实现的一个或多个函数并安排链接器读取该静态库文件作为附加输入来使用静态库。在构建过程中,链接器将解析所有引用,包括对静态库中实现的函数的引用。静态库通常与描述库中实现的功能的头文件配对。

动态链接库是另一种方法分享逻辑。动态库也是二进制文件(通常带有 .DLL 扩展名)。与静态库不同,DLL 不用作链接器的输入。相反,DLL 在程序执行期间动态加载。 DLL 可以通过调用 LoadLibraryEx 显式加载和 GetProcAddress 或在消耗程序已加载。

Programmers often find they have some code they would like to use in several programs, or code they would like to allow other programmers to make use of. They could copy-and-paste the logic into every program, or they could place the logic in common header and implementation files that they include in every project. Neither of those approaches is terribly elegant (or efficient).

Static libraries are one way to share logic so that other programs and programmers can make use of it. A static library is a binary file (often with a .LIB extension) suitable for input to the linker. A programmer consumes the static library by writing code to call one or more functions implemented in the static library and by arranging for the linker to read that static library file as an additional input. During the build, the linker will resolve all references including those to functions implemented within the static library. Often a static library is paired with a header file that describes the functions implemented in the library.

Dynamic Link Libraries are another way to share logic. Dynamic libraries are also binary files (often with a .DLL extension). Unlike static libraries, DLLs are not used as input to the linker. Instead, DLLs are loaded dynamically during program execution. DLLs may be explicitly loaded by calls to LoadLibraryEx and GetProcAddress or implicitly loaded when the consuming program is loaded.

揽月 2024-11-16 11:38:54

静态库是包含在二进制文件中的库。之所以说它是静态的,是因为当链接器运行时它会链接到您的程序。 DLL 是动态链接库,因此它是在程序加载到内存中时(而不是在编译和链接时)与二进制程序链接的共享代码。

A static library is a library that is included into your binary. It's said to be static because it's linked against your program when the linker runs. A DLL is a dynamically linking library, so it's shared code that is linked against your binary program when the program is loaded into memory, not when it's compiled and linked.

清泪尽 2024-11-16 11:38:54

名称说明了一切 - 静态库是静态的(使用链接器链接它们进行编译,它们成为程序的一部分),DLL(动态链接库)在运行时通过文件名动态链接,然后调用它们的方法。这是外部的。

The names say it all - static libraries are static (you compile with them linked using a linker and they become part of your program) and DLLs (dynamically linked libraries) are linked to dynamically at runtime, by filename, then you call their methods. It's external.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文