lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

2009/12/9 Carsten Fuchs <>
Hi Martin,

Martin C. Martin schrieb:

What libraries would someone recommend for binding Lua to parts of a large, existing C++ code base?  It needs to work in both Windows and Linux.  I'm looking at LuaPlus (I know, it's a lot more than just a C++ binding), but perhaps that's not the place to start?

When I started binding Lua to my C++ code in the Cafu game engine <>, my goals were to keep everything as straightforward  and with as few additional layers of code as possible, and thus, although I looked into them, I never used any of the available C++-binding libraries, but just the techniques explained in the PiL2 book.

While this route certainly takes longer in order to see the first results and in fact may seem cumbersome in a sense (yes, you start thinking about putting the resulting code into a library of your own... which in a sense means re-inventing the wheel), I still found the results worthwhile: My code is very short, clean, and I fully understand all the details both on the Lua and on the C++ side.  :-)  (And I thoroughly learned Lua and its C API this way.)

So my recommendation is to start with the PiL2 book, and only turn to the libraries if you cannot or don't want to take the "hand-made" approach.

Best regards,

    Cafu - The Game and Graphics Engine for
multiplayer, cross-platform, real-time 3D Action
           Learn more at

It depends on what you want from the library which one you should try. For example as you want it to be cross platform that rules out a couple of them. Do you want it to use vanilla Lua or are you OK with it making adjustment to the Lua core, remembering that many addons and debuggers for Lua with a changed core may not work. Then there seems to be some with are no longer in development and also do you want to preform the binding yourself or do you want it to be automatic and the library parses your input files?

If you are thinking of going down the reinvent the wheel route the there is a comparision of the different methods in IIRC Game Programming Gems 6, also some details to consider in an article in Lua Programming Gems. Personally I would say do not invest the time in reinventing the wheel and instead use a try and tested library, yet if everyone did this there would not be so many options (I hold my hand up :) ).

Sorry but if I were to recommend a library it would be a biased answer so I will leave it at that.