lua“stub”的目的是什么? dll窗口 [英] What's the purpose of the lua "stub" dll for windows

查看:217
本文介绍了lua“stub”的目的是什么? dll窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑将Lua并入C ++项目,并且由于 Luabinaries

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.

根据文档...


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

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.

为什么?在连接第三方DLL之前,我从来不需要存根DLL?

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

推荐答案

存根库是一个 .lib 文件,而不是一个DLL。它包含DLL中所有导出函数的函数声明,它将调用转换为DLL本身。因此,如果你要构建一个你想链接到 lua51.dll 的应用程序,你可以告诉链接器链接 lua51.lib ,并且对导出的函数的所有调用将被转发到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.

只有当静态链接到DLL时才需要它在应用程序运行时自动加载)。在$ code> LoadLibrary 动态加载DLL时不需要。

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.

为什么他们有两个不同的DLL,手册说:

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


LuaBinaries DLL包中有一个名为lua51.dll的dll代理。它可以用来替换其他发行版发布的其他lua51.dll。它将简单地将呼叫转发到lua5.1.dll。在转发中没有编译源代码。

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.

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

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.

这篇关于lua“stub”的目的是什么? dll窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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