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:

Regarding Lua function callback.
Example of callback registration:

Invoke Callback:


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?


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.

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


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