错误加载模块未定义的符号:luaL_setfuncs [英] Error loading module undefined symbol: luaL_setfuncs

查看:3771
本文介绍了错误加载模块未定义的符号:luaL_setfuncs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个C模块从一个Lua脚本调用。我的工作在Debian Linux上。我用mysql代理和Lua 5.2。我创建了(从教程​​复制)到被调用一些示例功能。

I am trying to create a C module to be called from a lua script. I am working on debian linux. I am using mysql-proxy and lua 5.2. I have created (copied from a tutorial) some example functions to be called.

装载机的定义是这样的:

The loader is defined like this:

int luaopen_luacall(lua_State* l)
{

    luaL_newlibtable(l, luacall);
    luaL_setfuncs(l, luacall, 0);
    return 1;
}

要从LUA调用这个我用这个code:

To call this from lua I use this code:

luacall = require("luacall")
local f = luacall.fun1()

我已经使用这个命令编译它:

I have compiled it with this command:

g++ -shared -Wl,-E,-soname,libluacall.so -o luacall.so luacall.c  -fPIC -llua -ldl

当我尝试运行该脚本,我得到的要求命令以下错误:

When I try to run the script I get the following error on the require command:

 error loading module 'luacall' from file '/usr/lib/mysql-proxy/lua/luacall.so':
        /usr/lib/mysql-proxy/lua/luacall.so: undefined symbol: luaL_setfuncs

我真的失去了什么我做错了。

I am really lost on what I am doing wrong.

推荐答案

我想我找到了问题(还没有解决):mysql的代理内部运行的embended LUA库

I think I found the problem (not yet the solution): Mysql-proxy runs internally an embended lua library.

mysql-proxy -V

给作为结果

mysql-proxy 0.8.1
  chassis: mysql-proxy 0.8.1
  glib2: 2.30.2
  libevent: 2.0.19-stable
  LUA: Lua 5.1.4
    package.path: /usr/lib/mysql-proxy/lua/?.lua
    package.cpath: /usr/lib/mysql-proxy/lua/?.so
-- modules
  admin: 0.8.1
  proxy: 0.8.1

所以我跑错Lua版本。我认为,这解释了luaL_setfuncs错误。我已经看到,即便是0.8.4版本,包括该版本的Lua,所以我将不得不重新改写C库。

So I am running the wrong lua version. I think that this explains the luaL_setfuncs error. I have seen that even the 0.8.4 version includes this version of lua, so I will have to rewrite the C library.

模块的最后code结尾是这样的(和运行!!!):

the final code of the module ends like this (and runs!!!):

static const struct luaL_Reg my_luacall[] = {
    {"trasnquery", trasnquery},
    {"fun2", function_2},
    {NULL, NULL}
};

int luaopen_luacall(lua_State* l)
{
    luaL_register(l, "luacall", my_luacall);
    return 1;
}

这篇关于错误加载模块未定义的符号:luaL_setfuncs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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