Lua 5.2:"检测到多个虚拟机"。

我有一个简单的程序,在 Visual C++ 2008 Express 中将其制作为 dll:

#include <lua52/lua.h>
#include <lua52/lualib.h>
#include <lua52/lauxlib.h>
#pragma comment(lib,"lua52.lib")
#include <stdio.h>

int needless(lua_State *L)
{
printf("bullshit\n");
return 0;
}
static const struct luaL_Reg noise[] = {
    {"needless",needless},
    {NULL,NULL}
};
__declspec(dllexport) int __cdecl luaopen_noise(lua_State *L)
{

luaL_newlib(L, noise);
    return 1;
}

当我在 lua5.2 解释器中使用 "import noise" 链接生成的 dll 时,我会出现“检测到多个 lua VM”错误,原因我不明白。我该怎么办才能让它工作?

点赞
用户107090
用户107090

Lua libraries written in C should not include a copy of the Lua core library.

我不了解 Visual C+,但这行代码可能是罪魁祸首:

#pragma comment(lib,"lua52.lib")
2014-04-28 13:08:56