[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Behavior of dlopen in MacOSX
- From: Tony Finch <dot@...>
- Date: Tue, 17 Jan 2012 20:21:04 +0000
Antonio Scuri <scuri@tecgraf.puc-rio.br> wrote:
>
> Inspecting the code, I changed the following line:
>
> void *lib = dlopen(path, RTLD_NOW | (seeglb ? RTLD_GLOBAL : RTLD_LOCAL));
>
> to (the same as it was in Lua 5.1):
>
> void *lib = dlopen(path, RTLD_NOW);
>
> Then it works.
dlopen() without an explicit RTLD_GLOBAL or RTLD_LOCAL flag is not
portable. On Mac OS X the default is RTLD_GLOBAL but on many other systems
it is RTLD_LOCAL.
You need to arrange for the right value in the seeglb parameter. For
instance,
package.loadlib (libname, funcname)
Dynamically links the host program with the C library libname.
If funcname is "*", then it only links with the library, making the
symbols exported by the library available to other dynamically linked
libraries. Otherwise, it looks for a function funcname inside the
library and returns this function as a C function. (So, funcname must
follow the prototype lua_CFunction).
The require() mechanism passes luaopen_<modname> as the function name,
so when loading modules in the usual way the RTLD_LOCAL flag is set.
Tony.
--
f.anthony.n.finch <dot@dotat.at> http://dotat.at/
Trafalgar: Variable 3 in northwest, northerly veering northeasterly 4 or 5,
increasing 6 at times in southeast. Moderate or rough. Rain or showers.
Moderate or good.