lua“存根”的目的是什么?适用于 Windows 的 DLL

发布于 2024-08-31 08:10:15 字数 342 浏览 4 评论 0原文

我正在考虑将 Lua 合并到 C++ 项目中,并且对 Luabinaries

根据文档...

在 Windows 中您的库或应用程序 必须与存根库链接。一个 存根库是一个只包含 函数声明将 将您的 DLL 与 Lua DLL 绑定。

为什么?我以前在与第三方 DLL 链接时从未需要过存根 DLL?

I'm looking at incorporating Lua into a C++ project, and am a bit confused by the presence of the two binaries (lua51.dll and lua5.1.dll) in the distribution from Luabinaries.

According to the docs...

In Windows your library or application
must be linked with a stub library. A
stub library is a library with only
the function declarations that will
bind your DLL with the Lua DLL.

Why? I've never needed stub DLLs before when linking with third-party DLLs?

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

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

发布评论

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

评论(2

无法回应 2024-09-07 08:10:15

存根库是一个 .lib 文件,而不是 DLL。它包含 DLL 中所有导出函数的函数声明,这些函数只是将调用转发到 DLL 本身。因此,如果您构建一个想要与 lua51.dll 链接的应用程序,您可以告诉链接器与 lua51.lib 链接,并且所有对导出函数的调用都将被转发到DLL。如果不这样做,链接时会出现很多“无法解析的外部符号”错误。

仅当与 DLL 静态链接时才需要这样做(以便在应用程序运行时自动加载它)。使用 LoadLibrary 动态加载 DLL 时不需要它。

关于为什么他们有两个不同的DLL,手册是这样说的:

LuaBinaries DLL 包有一个名为“lua51.dll”的 dll 代理。它可以用来替换其他发行版发布的“lua51.dll”。它只会将调用转发到“lua5.1.dll”。转发中不涉及编译源码。

基本上,一些现有的应用程序与 lua5.1.dll 链接,而其他应用程序与 lua51.dll 链接,并且他们希望同时支持它们。无论如何,这与存根库无关。

A stub library is a .lib file, not a DLL. It contains function declarations for all the exported functions in the DLL, which just forward the call into the DLL itself. So if you build an application that you want to link with lua51.dll, you tell the linker to link with lua51.lib, and all calls to exported functions will be forwarded to the DLL. If you didn't do this, you would get a lot of "unresolved external symbol" errors when linking.

This is only needed when statically linking with a DLL (so that it is loaded automatically when the application is run). It is not needed when loading the DLL dynamically with LoadLibrary.

Regarding why they have two different DLLs, The manual says this:

The LuaBinaries DLL packages have a dll proxy called "lua51.dll". It can be used to replace other "lua51.dll" released by other distributions. It will simply forward calls to the "lua5.1.dll". There is no compiled source code involved in the forwarding.

Basically, some existing applications link with lua5.1.dll while others link with lua51.dll and they want to support them both. In any case this is not related to the stub libraries.

无法回应 2024-09-07 08:10:15

我相信这与 __declspec(import) 和 __declspec(export) 与 GetProcAddress 有关。然而,我实际上并不确定。

I believe it's to do with __declspec(import) and __declspec(export) vs GetProcAddress. However, I don't actually know for sure.

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