【发布时间】:2012-01-23 01:34:24
【问题描述】:
我一直在尝试将 lua 嵌入 c++ 应用程序,但无济于事,因为编译器抱怨“lua_open”。我使用的是 Lua 5.2。
我发现很多文章声称 lua_open() 在第五个版本中被替换了,但没有一个提到什么。
这是我要编译的代码
extern "C" {
#include "../lua/lua.h"
#include "../lua/lualib.h"
#include "../lua/lauxlib.h"
}
int main()
{
int s=0;
lua_State *L = lua_open();
// load the libs
luaL_openlibs(L);
luaL_dofile(L,"example.lua");
printf("\nDone!\n");
lua_close(L);
return 0;
}
【问题讨论】:
-
lua_open已不在 5.1 手册中。它仅用于兼容性,现已在 5.2 中删除。 -
另请参阅这个非常有用的堆栈溢出答案,其中包含 lua_Alloc() 函数的示例以及指向 lua 文档的链接。 stackoverflow.com/questions/3880798/lua-runs-out-of-memory
-
这是第二个堆栈溢出答案,提供了有关 lua 内存分配的更多细节stackoverflow.com/questions/11324117/…
标签: c++ lua undefined embedding