Hello,
I've made a simple patch to rename some functions in chdkptp, so that lua can import them as libraries (eg require('chdkptp'))
This is pretty much a blind patch, as I do not have devices to test it with, but it should hopefully work
made against chdkptp r571.
Thanks for doing this, it should be quite useful.
I looked at this some more. There's quite a bit more that needs to be done to really make it work, particularly on windows.
It's still something I would like to add, but it's going to be a bit more than merging the patch.
A few notes:
Since the luaopen_* functions now return an int, so they need to return a value. In general they should return 1 with table created for the module on top of the stack (in Lua 5.2, they really shouldn't set a global).
On windows, the luaopen_* and other public functions need to be exported, either using __declspec(dllexport) or a .def file.
When linking, the libraries like chdkptp lbuf and liveimg need to be linked with a shared Lua and IUP, CD etc. They should probably also be linked to the shared versions of the other chdkptp libraries (e.g. liveimg to the shared lbuf rather than lbuf.o)
I'm not sure it's worth making lbuf, liveimage etc all separate dlls. Lua can load mutliple sub-modules from a single dll/so, which might make the build configuration simpler.
edit:
I should add that building lbuf with a shared Lua is somewhat dangerous. It assumes that it can use C stdio functions on the FILE * used by the Lua IO library. If Lua and lbuf are compiled with different C libraries, this will fail. This is likely if using a pre-built Lua on windows.