lua-users home
lua-l archive

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


On 23 February 2012 15:35, Gaspard Bucher <gaspard@teti.ch> wrote:
> The problem is that this is not "normal" behavior for shared libraries (to
> peek inside the running app to get it's code). This can be enabled by adding
> "RTLD_GLOBAL" in loadlib.c with:
>
> dlopen(path, RTLD_NOW|RTLD_GLOBAL);
>
> But instead of using a custom lua, I will see if I can remove these
> dependency chains.

I've dealt with this issue already - I want to split up the common
codebase of various modules of lqt (qtcore, qtgui, ...) to a separate
library (lqt.so) and use it as an entrypoint, so that the user can
write something like:

    require 'lqt' {'core', 'gui'}

However, the problem is that lqt.so in Lua 5.1 does not export the
symbols, because it only uses RTLD_NOW, and the RTLD_GLOBAL not
explicitly written. On Mac OS X, RTLD_GLOBAL is the default, and on
Linux, RTLD_LOCAL is the default.

In Python, it is possible to change the way dlopen() works from script
[1]. Lua 5.2 allows you to use package.loadlib with '*' as a second
parameter to force RTLD_GLOBAL [2][3].

[1] http://stackoverflow.com/questions/8361437/linker-error-lunatic-python-lua-requiresocket-undefined-symbol-lua-getme/8403467#8403467
[2] http://www.lua.org/manual/5.2/manual.html#pdf-package.loadlib
[3] http://www.lua.org/source/5.2/loadlib.c.html - see the first
ll_load() function