20
我一直在試圖將lua嵌入到C++應用程序中,但因爲編譯器抱怨「lua_open」,所以無濟於事。我正在使用Lua 5.2。在C++中嵌入Lua
我發現很多聲稱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中刪除。 – lhf 2011-12-18 15:20:13
另請參閱這個非常有用的堆棧溢出回答,其中包含lua_Alloc()函數的示例,其中包含指向lua文檔的鏈接。 http://stackoverflow.com/questions/3880798/lua-runs-out-of-memory – 2012-12-15 16:54:31
這是第二個堆棧溢出的答案,給出了一些關於lua內存分配的更多細節http://stackoverflow.com/questions/11324117/怎麼辦現代-VMS-手柄的內存分配 – 2012-12-15 17:06:32