在Lua 5.2中使用“module”函数? [英] Using the 'module' function in Lua 5.2?

查看:910
本文介绍了在Lua 5.2中使用“module”函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个VC ++项目,它使用Lua 5.2进行脚本化。

我试图在这个项目中实现MySQL兼容性。

我没有这个项目,所以我想更改尽可能少的源代码(如果有的话)。

我已从此扩展程序进入与可执行文件相同的基目录...在我的 Main.lua 文件中,我已添加 require('DBI') rel =nofollow>此维基页

I have a VC++ project which uses Lua 5.2 for scripting.
I am trying to implement MySQL compatibility into this project.
I do not own this project, so I would prefer to change as little source code as possible, if any at all.
I have downloaded and unzipped the files from this extension into the same base directory as the executable... and in my Main.lua file, I have added the line require('DBI') as stated to do so on this wiki page.

但是当我运行应用程序并执行脚本时, >

But when I run the application and execute the script, I get:

LUA Fail:
C:\Path\To\bin\DBI.lua:3: attempt to call global 'module' (a nil value)

> module 函数在Lua 5.2中折旧...

但是这个扩展以及其他MySQL扩展需要使用模块函数。

After some light reading, I found out that the module function was depreciated in Lua 5.2...
But this extension, as well as other MySQL extensions, require the use of the module function.

推荐答案

p>您可能需要使用LUA_COMPAT_MODULE编译您的Lua实例;根据源代码:LUA_COMPAT_MODULE控制与以前的模块功能模块(Lua)和'luaL_register'(C)的兼容性。

You may need to compile your Lua instance with LUA_COMPAT_MODULE; according to the source code: "LUA_COMPAT_MODULE controls compatibility with previous module functions 'module' (Lua) and 'luaL_register' (C)".

这将不够虽然模块本身是用Lua 5.1 API编写的。您可以尝试找到其Lua 5.2版本,或使用像Peter Cawley的 TwoFace 允许Lua 5.2程序加载大多数5.1 C库而不需要任何重新编译。

This won't be enough though as the module itself is written with Lua 5.1 API in mind. You can either try to find its Lua 5.2 version or use something like Peter Cawley's TwoFace that "allows a Lua 5.2 program to load most 5.1 C libraries without the need for any recompilation".

这篇关于在Lua 5.2中使用“module”函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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