c++中运行lua

下载lua源码将src下面除了 lua.c和luac.c 的文件全部添加到项目中

#include <iostream>
#include "lua.hpp"

int main()
{
  lua_State* L = luaL_newstate();
  luaL_dostring(L, "x = 42");
  lua_getglobal(L, "x");
  lua_Number x = lua_tonumber(L, 1);
  printf("x = %d
", (int)x);
  lua_close(L);
}
原文地址:https://www.cnblogs.com/ajanuw/p/13667793.html