c++ - luabind: cannot access global variable -
i have c++ class want give access in lua script through global variable, when try use following error: terminate called after throwing instance of 'luabind::error' what(): lua runtime error baz.lua:3: attempt index global 'foo' (a nil value)aborted (core dumped) my lua script (baz.lua) looks this: -- baz.lua frames = 0 bar = foo:createbar() function baz() frames = frames + 1 bar:settext("frame: " .. frames) end and i'm made simple , short (as could) main.cpp recreates problem: #include <memory> #include <iostream> extern "c" { #include "lua.h" #include "lualib.h" #include "lauxlib.h" } #include <boost/ref.hpp> #include <luabind/luabind.hpp> class bar { public: static void init(lua_state *l) { using luabind::module; using luabind::class_; module(l) [ class_<bar>("bar") .def("settext", &bar::settext)...