lua-users home
lua-l archive

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


Hi All,
  I have problem with the way lua open libraries using dlopen:

static void *ll_load (lua_State *L, const char *path) {
 void *lib = dlopen(path, RTLD_NOW);
 if (lib == NULL) lua_pushstring(L, dlerror());
 return lib;
}

I need lua to use the flag RTLD_GLOBAL and I want my library to be
loaded in a standard lua interpreter. I don't know if anyone else had
problems with this, but I'm proposing change dlopen using the same
approximation as python:

(this is in http://docs.python.org/lib/module-sys.html)
setdlopenflags( n)   Set the flags used by the interpreter for
dlopen()   calls, such as when the interpreter loads extension
modules.  Among   other things, this will enable a lazy resolving of
symbols when   importing a module, if called as sys.setdlopenflags(0).
To   share symbols across extension modules, call as
sys.setdlopenflags(dl.RTLD_NOW | dl.RTLD_GLOBAL)

In this way dlopen could be used as now, and with very little change
user will be able to manage how libraries are loaded.

By the way... I will need to show an error ("this can not be uses in a
standard lua interpreter, please change line 69 of loadlib.c  with
RLD_NOW|RTLD_GLOBAL")  :P

Best regards,
   Jose L.

PD: Related threads :
http://lua-users.org/cgi-bin/namazu.cgi?query=RTLD_NOW&idxname=lua-l&max=20&result=normal&sort=score

--
 Jose L. Hidalgo Valiño (PpluX)
 ---- http://www.pplux.com ----