So I'm trying to embed Lua into C++ and every time I try and compile I get this error:
/root/NetBeansProjects/test/main.cpp:20: undefined reference to `luaL_newstate'
/root/NetBeansProjects/test/main.cpp:31: undefined reference to `lua_settop'
/root/NetBeansProjects/test/main.cpp:35: undefined reference to `luaL_loadfilex'
/root/NetBeansProjects/test/main.cpp:35: undefined reference to `lua_pcallk'
/root/NetBeansProjects/test/main.cpp:38: undefined reference to `lua_close'
I've been searching for a solution for hours but I can't find anything helpful.
I installed Lua: apt-get install lua5.2 lua5.2-dev
Here's my code:
#include <cstdlib>
#include <iostream>
#include <string.h>
#include <string>
#include <lua5.2/lua.hpp>
using namespace std;
int main() {
  // create new Lua state
  lua_State *lua_state;
  lua_state = luaL_newstate();
  // load Lua libraries
  static const luaL_Reg lualibs[] ={
    { "base", luaopen_base},
    { NULL, NULL}
  };
  const luaL_Reg *lib = lualibs;
  for (; lib->func != NULL; lib++) {
    lib->func(lua_state);
    lua_settop(lua_state, 0);
  }
  // run the Lua script
  luaL_dofile(lua_state, "test.lua");
  // close the Lua state
  lua_close(lua_state);
  return 0;
}
What am I doing wrong?
