捆绑用于嵌入式和静态链接的Lua运行时的其他Lua库 [英] Bundling additional Lua libraries for embedded and statically linked Lua runtime

查看:94
本文介绍了捆绑用于嵌入式和静态链接的Lua运行时的其他Lua库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过静态链接Lua将Lua嵌入到项目中的Win32中(不,我无法切换到DLL).我想捆绑更多使用本机代码的Lua扩展-不仅仅是纯.lua文件.具体来说,我想将史蒂夫·多诺万的winapi 捆绑在一起,其中包括一些lua文件和一些.c文件.

该怎么做?

解决方案

您需要做两件事.首先,您必须将Lua DLL项目编译为非DLL项目.由于它们原本打算用作DLL模块,所以在其构建系统中可能没有相应的规定.这意味着您必须自己做.摆脱DLL主要功能和其他专门的DLL功能(但要注意它们的作用,如果重要,请确保复制它们).并确保您更改所有试图将Lua包含在动态链接中的#define.

所有Lua模块DLL导出一个或多个形式为luaopen_*的函数,其中*是要加载的模块的名称.此功能可能会用declspec()表示法修饰.通常,该表示法是通过预处理器宏完成的,但事实并非如此.无论哪种方式,都将其删除,然后将其转换为普通的函数声明.

现在,一旦创建了lua_State对象,只需用lua_State调用该luaopen_*函数即可.

I have embedded Lua on Win32 in my project by means of statically linking it in (no, I can't switch to DLL). I would like to bundle more Lua extensions that use native code - not just pure .lua files. Specifically, I want to bundle Steve Donovan's winapi which comes as some lua files and some .c files.

How to do it?

解决方案

You need to do two things. First, you have to compile the Lua DLL projects into non-DLL projects. Since they're intended to be DLL modules, they probably won't have provisions for this in their build systems. That means you have to do it yourself. Get rid of the DLL main functions and other specialized DLL functions (but take note of what they do and make sure you replicate it if it's important). And make sure that you change any #defines that try to include Lua with dynamic linking.

All Lua module DLLs export one or more functions of the form luaopen_*, where * is the name of the module to load. This function will likely be decorated with declspec() notation. Typically, the notation is done via a preprocessor macro, but it may not be. Either way, remove it, turning it into a normal function declaration.

Now, once you have created your lua_State object, just call that luaopen_* function with your lua_State.

这篇关于捆绑用于嵌入式和静态链接的Lua运行时的其他Lua库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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