I am running after compiling the sample code. results do not write on the screen
#include <stdio.h>
#include <string.h>
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
int main(int argc, char* argv[]) {
// Create new Lua state and load the lua libraries
lua_State *L = luaL_newstate();
luaL_openlibs(L);
// Tell Lua to load and run the file example.lua
luaL_loadfile(L, argv[1]);
// Close the Lua state
lua_close(L);
return 0;
}
If this code is giving this error "PANIC: unprotected error in call to Lua API (no calling environment)"
#include <stdio.h>
#include <string.h>
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
int main(int argc, char* argv[]) {
// Create new Lua state and load the lua libraries
lua_State *L = luaL_newstate();
luaopen_io(L); // provides io.*
luaopen_base(L);
luaopen_table(L);
luaopen_string(L);
luaopen_math(L);
luaopen_table(L);
// Tell Lua to load and run the file example.lua
int lua_exec = luaL_loadfile(L, argv[1]);
if(lua_exec == 0){
// execute Lua program
lua_exec = lua_pcall(L,0,LUA_MULTRET,0);
}
// Close the Lua state
lua_close(L);
return 0;
}
Waiting for your help friends
Thank you