Sign in to follow this  

luabind 0.7 / lua 5.1 && lua_pushcclosure

This topic is 3927 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm currently playing with luabind, but am running into problems. I'm not building it as a library, but am just including all headers from the src directory, so the lead in to my test program looks like this:
#include <lua.hpp>
#include <lualib.h>
#include <lauxlib.h>

#include <luabind/luabind.hpp>

#include <src/class.cpp>
#include <src/class_info.cpp>
#include <src/class_registry.cpp>
#include <src/class_rep.cpp>
#include <src/create_class.cpp>
#include <src/error.cpp>
#include <src/find_best_match.cpp>
#include <src/function.cpp>
#include <src/implicit_cast.cpp>
#include <src/link_compatibility.cpp>
#include <src/object_rep.cpp>
#include <src/open.cpp>
#include <src/overload_rep.cpp>
#include <src/pcall.cpp>
#include <src/ref.cpp>
#include <src/scope.cpp>
#include <src/stack_content_by_name.cpp>
#include <src/weak_ref.cpp>
#include <src/wrapper_base.cpp>



When I compile I get some errors - a redefinition of struct luabind::detail::method_name (which appears in class.cpp and class_ref.cpp), and some syntax errors in ref.cpp, and for the life of me I can't work out why they are appearing. Has anyone tried this recently and had any issues? For the record I am using VS 2003 pro with luabind 0.7 and lua 5.1. I vaguely remember reading somewhere that these versions of luabind and lua might not be compatible - and indeed the introduction to the luabind documentation does explicitly say lua 5.0. Is this still the case? 2nd question: Has anyone ever found any reasonable documentation for lua_pushcfunction / lua_pushcclosure? I was also writing a light-weight wrapper, for education purposes as well as the fact that luabind is a beast, and exposing functions to Lua relies upon this function (as well as the function signature int (*func)(lua_State*), which is a whole 'nother issue). I'd like to write an exposure function, but am struggling without knowing what lua_pushcclosure really does. Been through the luabind source, but it's very heavily templated :( So, in summary: Am I using incompatible versions of luabind and lua? If not, has anyone else had any recent issues with compilation of luabind? Or can anyone see a header I am / am not including that I should be? Has anyone ever found any decent information on lua_pushcclosure? Jim. Edit: Don't you hate it when that happens? After spending all morning googling, after writing this post I google "lua 5.1 luabind 0.7" and find some topics of interest. Bah humbug. Still interested in any details on lua_pushcclosure. More edits: Built luabind as a static library, seems to be working. Ah well. If you made it this far, thanks for reading ;) [Edited by - JimPrice on March 6, 2007 3:58:07 PM]

Share this post


Link to post
Share on other sites
- The current release of Luabind is compatible only with Lua 5.0, -not- Lua 5.1

- The latest SVN checkout of Luabind however -is- compatible with Lua 5.1, they just haven't made an official release yet

- Sorry, I don't have any info for you on lua_pushclosure. And yes, Luabind is a beast [smile]



You might be also interested to know that Luabind recently setup a trac system (not officially mentioned anywhere AFAIK, but its in the mailing list). It has additional info on Luabind such as a roadmap and community created documentation in the wiki. The URL is http://code.rasterbar.com/luabind

Share this post


Link to post
Share on other sites
hi there
to compile luabind07 and lua51, you need to do the following :

1 : replace "#undef LUA_COMPAT_GETN" with "#define LUA_COMPAT_GETN", which is located in file luaconf.h, line 322;
2 : if using VC2005, dont compile your project with 'UNICODE' defined, change it to "MBCS";

after above two steps it should compile, hope its helpful

Share this post


Link to post
Share on other sites
lua_pushcclosure

I assume you know what a closure is first. If not, I suggest you google it.

C:

int foo(lua_State *L) {
lua_pushvalue(L, lua_upvalueindex(1));
return 1;
}

void registerFoo(lua_State *L) {
lua_pushnumber(L, 42);
lua_pushcclosure(L, foo, 1);
lua_setglobal(L, "foo");
}

int luaopen_foo(lua_State *L) {
registerFoo(L);
return 0;
}



Lua:

require "foo"
print(foo()) --> 42


Share this post


Link to post
Share on other sites

This topic is 3927 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this