Can anybody explain this for me? It used to work on an older system with
lua5.1. i'm now using lua5.2, luabind version us 0.9.1 (on both systems) g++ -o lua lua.cpp -lluabind -llua5.2 -ldl -I /usr/include/lua5.2 ./lua lua runtime error [string "function test(t)..."]:2: attempt to concatenate field 'value' (a function value) extern "C" { #include "lua.h" #include "lualib.h" #include "lauxlib.h" } #include <luabind/luabind.hpp> #include <iostream> struct Test { Test(int v) : value(v) {}; ~Test() {}; int value; }; int DebuggerFunc(lua_State* L) { luabind::object error_msg(luabind::from_stack(L, -1)); std::cerr << error_msg << std::endl; return 0; } int main() { lua_State *L = luaL_newstate(); luabind::open(L); luabind::module(L) [ luabind::class_<Test>("Test") .def(luabind::constructor<int>()) .def_readonly("value",&Test::value) ]; luaL_dostring( L, "function test(t)\n" " print(\"value : \" .. t.value)\n" "end\n" ); Test t(4); try { luabind::call_function<int>(L, "test", &t); } catch (const luabind::error &er) { std::cerr << er.what() << std::endl; lua_State* Ler=er.state(); DebuggerFunc(Ler); } catch (...) { std::cerr << "Unknown error!" << std::endl; } lua_close(L); } ------------------------------------------------------------------------------ _______________________________________________ luabind-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/luabind-user |
Hello,
Your Lua code should not be working at all, since no libraries are loaded and print isn't even defined. After adding luaL_openlibs(L); after creating the Lua state, it works fine for me: $ ./lua value : 4 Regards, Andreas Am 01.11.2014 um 18:45 schrieb [hidden email]: > Can anybody explain this for me? It used to work on an older system with > lua5.1. > > i'm now using lua5.2, luabind version us 0.9.1 (on both systems) > > g++ -o lua lua.cpp -lluabind -llua5.2 -ldl -I /usr/include/lua5.2 > ./lua > lua runtime error > [string "function test(t)..."]:2: attempt to concatenate field 'value' (a > function value) > > extern "C" { > #include "lua.h" > #include "lualib.h" > #include "lauxlib.h" > } > > #include <luabind/luabind.hpp> > #include <iostream> > > struct Test > { > Test(int v) : value(v) {}; > ~Test() {}; > int value; > }; > > > int DebuggerFunc(lua_State* L) > { > luabind::object error_msg(luabind::from_stack(L, -1)); > std::cerr << error_msg << std::endl; > return 0; > } > > int main() { > lua_State *L = luaL_newstate(); > luabind::open(L); > > luabind::module(L) > [ > luabind::class_<Test>("Test") > .def(luabind::constructor<int>()) > .def_readonly("value",&Test::value) > ]; > > luaL_dostring( > L, > "function test(t)\n" > " print(\"value : \" .. t.value)\n" > "end\n" > ); > > Test t(4); > > try { > luabind::call_function<int>(L, "test", &t); > } > catch (const luabind::error &er) > { > std::cerr << er.what() << std::endl; > lua_State* Ler=er.state(); > DebuggerFunc(Ler); > } > catch (...) > { > std::cerr << "Unknown error!" << std::endl; > } > lua_close(L); > } > > > ------------------------------------------------------------------------------ > _______________________________________________ > luabind-user mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/luabind-user ------------------------------------------------------------------------------ _______________________________________________ luabind-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/luabind-user |
oops, I had missed that out of the simplified test case, however it still
isn't working for me after adding that in :(. I guess lua or luabind is broken on my system (Linux Mint 17) > Hello, > > Your Lua code should not be working at all, since no libraries are > loaded and print isn't even defined. > After adding luaL_openlibs(L); after creating the Lua state, it works > fine for me: > > $ ./lua > value : 4 > > Regards, > Andreas > > > Am 01.11.2014 um 18:45 schrieb [hidden email]: >> Can anybody explain this for me? It used to work on an older system with >> lua5.1. >> >> i'm now using lua5.2, luabind version us 0.9.1 (on both systems) >> >> g++ -o lua lua.cpp -lluabind -llua5.2 -ldl -I /usr/include/lua5.2 >> ./lua >> lua runtime error >> [string "function test(t)..."]:2: attempt to concatenate field 'value' >> (a >> function value) >> >> extern "C" { >> #include "lua.h" >> #include "lualib.h" >> #include "lauxlib.h" >> } >> >> #include <luabind/luabind.hpp> >> #include <iostream> >> >> struct Test >> { >> Test(int v) : value(v) {}; >> ~Test() {}; >> int value; >> }; >> >> >> int DebuggerFunc(lua_State* L) >> { >> luabind::object error_msg(luabind::from_stack(L, -1)); >> std::cerr << error_msg << std::endl; >> return 0; >> } >> >> int main() { >> lua_State *L = luaL_newstate(); >> luabind::open(L); >> >> luabind::module(L) >> [ >> luabind::class_<Test>("Test") >> .def(luabind::constructor<int>()) >> .def_readonly("value",&Test::value) >> ]; >> >> luaL_dostring( >> L, >> "function test(t)\n" >> " print(\"value : \" .. t.value)\n" >> "end\n" >> ); >> >> Test t(4); >> >> try { >> luabind::call_function<int>(L, "test", &t); >> } >> catch (const luabind::error &er) >> { >> std::cerr << er.what() << std::endl; >> lua_State* Ler=er.state(); >> DebuggerFunc(Ler); >> } >> catch (...) >> { >> std::cerr << "Unknown error!" << std::endl; >> } >> lua_close(L); >> } >> >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> luabind-user mailing list >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/luabind-user > > > ------------------------------------------------------------------------------ > _______________________________________________ > luabind-user mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/luabind-user > ------------------------------------------------------------------------------ _______________________________________________ luabind-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/luabind-user |
I can confirm your error with luabind 0.9.1+dfsg-8, which is what Mint
17 is using. An update of libluabind and libluabind-dev to 0.9.1+dfsg-9 (from debian sid) resolves the problem. Regards, Andreas Am 01.11.2014 um 19:42 schrieb [hidden email]: > oops, I had missed that out of the simplified test case, however it still > isn't working for me after adding that in :(. > > I guess lua or luabind is broken on my system (Linux Mint 17) > >> Hello, >> >> Your Lua code should not be working at all, since no libraries are >> loaded and print isn't even defined. >> After adding luaL_openlibs(L); after creating the Lua state, it works >> fine for me: >> >> $ ./lua >> value : 4 >> >> Regards, >> Andreas >> >> >> Am 01.11.2014 um 18:45 schrieb [hidden email]: >>> Can anybody explain this for me? It used to work on an older system with >>> lua5.1. >>> >>> i'm now using lua5.2, luabind version us 0.9.1 (on both systems) >>> >>> g++ -o lua lua.cpp -lluabind -llua5.2 -ldl -I /usr/include/lua5.2 >>> ./lua >>> lua runtime error >>> [string "function test(t)..."]:2: attempt to concatenate field 'value' >>> (a >>> function value) >>> >>> extern "C" { >>> #include "lua.h" >>> #include "lualib.h" >>> #include "lauxlib.h" >>> } >>> >>> #include <luabind/luabind.hpp> >>> #include <iostream> >>> >>> struct Test >>> { >>> Test(int v) : value(v) {}; >>> ~Test() {}; >>> int value; >>> }; >>> >>> >>> int DebuggerFunc(lua_State* L) >>> { >>> luabind::object error_msg(luabind::from_stack(L, -1)); >>> std::cerr << error_msg << std::endl; >>> return 0; >>> } >>> >>> int main() { >>> lua_State *L = luaL_newstate(); >>> luabind::open(L); >>> >>> luabind::module(L) >>> [ >>> luabind::class_<Test>("Test") >>> .def(luabind::constructor<int>()) >>> .def_readonly("value",&Test::value) >>> ]; >>> >>> luaL_dostring( >>> L, >>> "function test(t)\n" >>> " print(\"value : \" .. t.value)\n" >>> "end\n" >>> ); >>> >>> Test t(4); >>> >>> try { >>> luabind::call_function<int>(L, "test", &t); >>> } >>> catch (const luabind::error &er) >>> { >>> std::cerr << er.what() << std::endl; >>> lua_State* Ler=er.state(); >>> DebuggerFunc(Ler); >>> } >>> catch (...) >>> { >>> std::cerr << "Unknown error!" << std::endl; >>> } >>> lua_close(L); >>> } >>> >>> >>> ------------------------------------------------------------------------------ >>> _______________________________________________ >>> luabind-user mailing list >>> [hidden email] >>> https://lists.sourceforge.net/lists/listinfo/luabind-user >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> luabind-user mailing list >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/luabind-user >> > > > ------------------------------------------------------------------------------ > _______________________________________________ > luabind-user mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/luabind-user ------------------------------------------------------------------------------ _______________________________________________ luabind-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/luabind-user |
Brilliant thanks. I can confirm that fixes my problem, at least in the test case. I'll try my main app tomorrow.
On 1 November 2014 19:34:42 GMT+00:00, Andreas Grob <[hidden email]> wrote: I can confirm your error with luabind 0.9.1+dfsg-8, which is what Mint -- Sent from my Android device with K-9 Mail. Please excuse my brevity. ------------------------------------------------------------------------------ _______________________________________________ luabind-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/luabind-user |
Just confirming that yes this fixed my real application to. Thanks a bunch.
On 1 November 2014 22:28:45 GMT+00:00, Daniel Squires <[hidden email]> wrote: Brilliant thanks. I can confirm that fixes my problem, at least in the test case. I'll try my main app tomorrow. -- Sent from my Android device with K-9 Mail. Please excuse my brevity. ------------------------------------------------------------------------------ _______________________________________________ luabind-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/luabind-user |
Free forum by Nabble | Edit this page |