了解LUA扩展DLL建筑/在静态链接的嵌入式LUA环境负荷 [英] Understanding lua extension dll building/loading in statically linked embedded lua environment

查看:153
本文介绍了了解LUA扩展DLL建筑/在静态链接的嵌入式LUA环境负荷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相对复杂的LUA环境,我想了解下会/可以工作。起始设置包括以下两个模块:

I have a relatively complex lua environment and I'm trying to understand how the following would/could work. The starting setup includes the following two modules:


  • 主要应用(LUA没有环境)

  • DLL(静态链接到Lua lib目录,其中包括跨preTER)

该dll被加载到主应用程序并运行LUA控制台间preTER和LUA API从控制台访问。

The dll is loaded into the main application and runs a lua console interpreter and a lua API accessible from the console.

现在,让我们说,我想扩大这个设置包括另一个DLL,将延长该LUA API,luasql为例。新的DLL需要,以建立对LUA链接,我的理解是,我不能对LUA静态链接因为现在是在过程中的LUA code两个非共享副本当我加载扩展DLL。然而,即使我建立了LUA核心的lib为DLL和反对其与扩展DLL链接,即LUA核心DLL不会在运行时由主应用程序或DLL主要装载。所以我的问题是:

Now, let's say I want to expand this setup to include another dll that would extend that lua API, luasql for example. The new dll needs to link against lua in order to build, and my understanding is that I cannot link against lua statically since there would now be two unshared copies of the lua code in process when I load the extension dll. However, even if I built the lua core lib as a dll and linked against it with the extension dll, that lua core dll would not be loaded at runtime by the main application or the primary dll. So my questions are:


  1. 如果我加载从LUA INTE preTER的扩展DLL在主DLL,考虑到LUA核心DLL将不会加载该怎么办?

  2. 如果我装了LUA核心DLL在运行时,如何将与静态链接LUA LIB冲突?

  3. 请问这两种情况下(在扩展DLL静态链接和动态链接/装入LUA DLL)导致在具有过程中的Lua内核code的两个副本?

  4. 在这种情况下,如果我试图调用从主dll的LUA环境/间preTER一个建/在扩展DLL加载的API函数,会发生什么?

  5. 还是卢阿有某种特殊的机制,用于加载提供新的C API函数,允许其绕过正常的链接规则机DLL?

希望我能提供足够的细节,使该问题的具体,如果没有,我会很乐意进一步细化方案/问题。

Hopefully I have provided enough details to make the questions specific, if not I will be happy to refine the scenario/questions further.

编辑:我已经看过<一个href=\"http://stackoverflow.com/questions/9245394/bundling-additional-lua-libraries-for-embedded-and-statically-linked-lua-runtime\">Bundling另外Lua库为嵌入式和静态链接的Lua运行,我相信它可能有助于在最终提供一个解决方案,但我想在连接器高度来认识它。

I have looked at Bundling additional Lua libraries for embedded and statically linked Lua runtime and I believe it may be helpful in providing a solution ultimately but I'd like to understand it at the linker level.

推荐答案

您可以不必在放入一个跨preTER情况(假设它是静态链接)并装载,针对链接模块点¯x用一个Lua间preTER,它加载间preTER的另一个副本DLL。这很可能会导致应用程序崩溃。你需要做的加载的DLL或者通过对与各国preTER该DLL链接或通过代理DLL(见下文),以使用已经加载的跨preTER。

You can't have the situation when you load one interpreter (let's say it's linked statically) and load a module X that is linked against a dll with a Lua interpreter, which loads another copy of the interpreter. This is likely to cause an application crash. You need to make the loaded dll to use the interpreter that is already loaded, either by linking against that dll with the interpreter or by using a proxy dll (see below).

您有两个主要选项:(1)使由主应用程序,又依赖于Lua的DLL加载DLLA;那么你可以没有任何问题的链接对Lua的DLL的所有其他Lua模块; (2)包括Lua的DLL注入DLLA,但保持Lua的方法暴露,这样Lua模块可以通过对DLLA链接。

You have two main options: (1) make dllA that is loaded by the main application that in turn depends on Lua dll; you can then link all other lua modules against Lua dll without any issues; or (2) include Lua dll into dllA, but keep Lua methods exposed so that lua modules can be linked against that dllA.

我觉得第一个选项是更简单,可能不要求对Lua模块的任何更改(只要你能保持Lua的名称DLL中相同的模块编译反对的)。

I think the first option is much simpler and likely not to require any changes to the Lua modules (as long as you can keep the name of the Lua dll the same as the one that the modules are compiled against).

我要提到另一种选择是,你仍然可以使用针对Lua的DLL编译Lua模块甚至具有相互的Lua preTER静态编译的应用程序。您需要使用代理DLL ;看到的解决方案和相关的讨论这个邮件列表线程

Another option I should mention is that you can still use Lua modules compiled against a Lua DLL even with applications that have the Lua interpreter statically compiled. You need to use a proxy DLL; see this maillist thread for the solution and related discussion.

这篇关于了解LUA扩展DLL建筑/在静态链接的嵌入式LUA环境负荷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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