As I mentioned before in the other thread, I have been having a really hard time trying to figure out how to get Lua modules to load successfully from inside the Lua plugin.
A few of them will load, but most of the time I end up with "undefined reference" errors when the module tries to call some C function from the Lua library.
After trying just about every combination of linker flags (and a few impossible ones) re-compiling, re-installing, and re-starting, again and again, all without any luck, I finally stumbled upon the solution - if I remove the G_MODULE_BIND_LOCAL flag from g_module_open() in plugins.c, everything works just fine.
But it might not be a good idea to let any and all plugins have access to the global namespace like that, so I wonder if there could be some way for a plugin to request this, maybe something like this...
Open the plugin normally, using the G_MODULE_BIND_LOCAL flag, and check for the existence of some symbol, e.g.
make_me_global=TRUE;
If that symbol is NOT found, or if it evaluates to FALSE, then continue on loading the plugin as always. But if the symbol exists and is true, then close the module and re-open it *without* the G_MODULE_BIND_LOCAL flag.
That should keep the performance hit to a minimum, and still keep compatibility with existing plugins.
Of course, plugins should only enable this if they really need it, and the ones that do should take some effort to avoid interfering with each other. ( Using static symbols when possible, and trying to use some hopefully unique naming prefix, etc. )
If you agree to this, I will try to work up a patch.
What do you think?
- Jeff