1

I am new to Lua and especially new to Luabind. When I tried to compile (with Clang++), my first file using Luabind:

    #define LUA_COMPAT_ALL
    #include <luabind/luabind.hpp>
    #include <luaconf.h>
    #include <iostream>

    int main() {

      lua_State *myLuaState = luaL_newstate();


      luabind::open(myLuaState);


      luaL_dostring(
        myLuaState,
        "function add(first, second)\n"
        "  return first + second\n"
        "end\n"
      );
      std::cout << "Result: "
           << luabind::call_function<int>(myLuaState, "add", 2, 3)
           << std::endl;

      lua_close(myLuaState);
    }

I got a whole heap of error messages.

So, I did a bit of looking around I found it had to do with my Lua version being 5.2 vs 5.1 and found that the solution was LUA_COMPAT_ALL (which I found out at Lua project compiling with errors (luabind)).

Unfortunately, I'm a bit of a scrub when it comes to Lua; so, I don't know where I put that.

I hope my question wasn't too stupid :)

Community
  • 1
  • 1
Ace shinigami
  • 1,374
  • 2
  • 12
  • 25
  • 1
    Lua 5.1 and 5.2 have some major differences. If you're committed to Lua 5.2, it looks like some people have taken luabind and made a new version that is more compatible with 5.2. https://github.com/rpavlik/luabind Maybe try that? – Adam B Feb 11 '16 at 04:13
  • @AdamB I installed boost (via brew) like the instructions suggested, but when I `bjam install` it returns [errors](http://pastebin.com/QJzjaVAe) – Ace shinigami Feb 11 '16 at 05:35

1 Answers1

1

Just defining it in your code should work, as told in the Lua source (CTRL+F for "LUA_COMPAT_ALL"): http://www.lua.org/source/5.2/luaconf.h.html

(It might've been in the manual, but removed from it later on)

EinsteinK
  • 745
  • 3
  • 8
  • @EinstienK I added `#include ` `#define LUA_COMPAT_AL` and i still get the errors http://pastebin.com/bx8vxiUW – Ace shinigami Feb 11 '16 at 20:55
  • @Julian First of all, it's named LUA_COMPAT_AL**L**, and second, you have to define it **before** including _luaconf.h_. EinsteinK is right so far but doesn't consider your big lack of C experience. – Youka Feb 11 '16 at 21:24
  • I fixed it but unfortunately it's returning the same error. – Ace shinigami Feb 11 '16 at 21:27