If you’re compiling in debug mode, you will probably have a lot of debug-info and symbols (luabind consists of a lot of functions). Also, if built in debug mode, no optimizations were applied, luabind relies on that the compiler is able to inline functions. If you built in release mode, try running strip on your executable to remove export-symbols, this will trim down the size.
Our tests suggests that cygwin’s gcc produces much bigger executables compared to gcc on other platforms and other compilers.
Yes you can, but you can only register explicit instantiations of the class. Because there’s no Lua counterpart to C++ templates. For example, you can register an explicit instantiation of std::vector<> like this:
module(L)
[
class_<std::vector<int> >("vector")
.def(constructor<int>)
.def("push_back", &std::vector<int>::push_back)
];
No, the destructor of a class is always called by luabind when an object is collected. Note that Lua has to own the object to collect it. If you pass it to C++ and gives up ownership (with adopt policy) it will no longer be owned by Lua, and not collected.
If you have a class hierarchy, you should make the destructor virtual if you want to be sure that the correct destructor is called (this apply to C++ in general).