luabind 0.7 / lua 5.1 && lua_pushcclosure

Started by
2 comments, last by Zorbfish 17 years, 1 month ago
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]
Advertisement
- 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

Hero of Allacrost - A free, open-source 2D RPG in development.
Latest release June, 2015 - GameDev annoucement

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
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

This topic is closed to new replies.

Advertisement