Lua binding

Is there any lua binding solutions that can bind a C++ class to lua? Including lua function callback.

Yes, you can write your own Native Extension (NE) and communicate between C/Cpp code and Lua code.
There is native extensions manual:


Example Extensions:

C API functions:
http://pgl.yoyo.org/luai/i/3.7+Functions+and+Types

Regarding Lua function callback.
Example of callback registration:

Invoke Callback:

1 Like

I know this, but I found If I want to bind a C++ class to lua, it has a lot of glue codes, Is there some solutions like tolua?

1 Like

Sorry for my misunderstanding.
Maybe @Mathias_Westerdahl could help with your question.

There are several tools for generating Lua bindings from header files etc I haven’t tried any of them myself though.

http://lua-users.org/wiki/BindingCodeToLua

I’ve heard of sol and sol2 in the list above and it is supposedly a very good solution.

2 Likes

No, I haven’t heard of anything like this. @britzl’s suggestions are probably a good approach though, if necessary.

1 Like