lua-users home
lua-l archive

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


On Sat, Apr 07, 2007 at 12:27:09AM +0200, Adrian Perez wrote:
> Sam Roberts <sroberts@bycast.com> wrote:
> 
> > On Tue, Apr 03, 2007 at 05:48:11PM -0300, Luiz Henrique de Figueiredo
> > wrote:
> >
> > If my memory hasn't failed, -dynamiclib creates things that can't be
> > loaded with NSBundle (the dyld-based stuff in loadlib.c, for example).
> > 
> > The distinction between them in OS X's Mach-O binary format, as far
> > as I could tell, is that bundles are for libraries loaded
> > programmatically at runtime ("plugins", lua modules would fit in this
> > category), and that dynamic libs are linked against an application
> > (dynamically linked, of course).  dlopen()/ELF makes no such
> > distinction, so maybe dlopen() on OS X is smoothing over the
> > difference, to help portability.
> 
> You're right, as far as I can recall, both dlcompat (and libdl in
> newer MacOSX releases) allow loading shared object code linked with
> "-dynamiclib", but it cannot be safely unloaded afterwards by means of
> dlclose() or equivalent calls to dyld functions. Shared object code
> created with "-bundle" *can* be effectively unloaded. Unloading of
> object code usually is not very important, but it may be desired (and
> even imprescindible!) for long-running applications, or in applications
> which can can upgrade their code on the fly while running.

And loadlib.c does unload libs when the state is closed (and perhaps
before?), causing fatal application errors if the lib cannot be
unloaded! So, -bundle is the way to go.

Sam