lua-users home
lua-l archive

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


> On 23 February 2012 21:28, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> > In 5.2, the function package.loadlib has an aditional parameter that
> > corresponds to this GLOBAL option. 'require' still links modules with
> > private names. If you want to link a C library to use its functions
> > directly from another C library, then you should load the library using
> > package;loadlib plus that option (instead of using require).
> 
> Can a library once opened with standard 'require' be "re-opened" with
> the GLOBAL option? Or does the library need to be opened with
> package.loadlib and '*' before other modules depending on it can be
> 'require'-d?

It must be opened with '*' first. Lua keeps the result of the first
'dlopen' for a library and reuses it for other calls. But it may be
a good idea to separate those auxiliary functions into a C library
that has no Lua function (and no 'luaopen_' function), so it is never
'require'd.

-- Roberto