lua-users home
lua-l archive

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


Hi,

Roberto Ierusalimschy wrote:
> > NSCreateObjectFileImageFromFile only loads bundles, NSAddImage only
> > loads dylibs.
> 
> Are you sure? I thought NSAddImage could load both bundles and dylibs...

osx$ cat >test.c
#include "lua.h"
int luaopen_test(lua_State *L) { return 0; }
^D
osx$ MACOSX_DEPLOYMENT_TARGET=10.3
osx$ export MACOSX_DEPLOYMENT_TARGET
osx$ cc -bundle -undefined dynamic_lookup -o bundle.so test.c
osx$ cc -dynamiclib -undefined dynamic_lookup -o dylib.so test.c
osx$ file *.so
bundle.so: Mach-O filetype=8 powerPC
dylib.so: Mach-O filetype=6 powerPC

*** Original lua-5.1-work3 using NSAddImage:

osx$ ./lua-5.1-work3 -e 'print(loadlib("dylib.so","_luaopen_test"))'
function: 0x6d990

osx$ ./lua-5.1-work3 -e 'print(loadlib("bundle.so","_luaopen_test"))'
nil	dyld: ./lua-5.1-work3 malformed library: bundle.so (not a Mach-O library file, bad filetype value)
	open

(ugh, seems to add LFs, too ...)

*** With my modifications using NSCreateObjectFileImageFromFile:

osx$ ./lua-5.1-work3-loadlib3 -e 'print(loadlib("dylib.so","_luaopen_test"))'
nil	cannot load library	open

osx$ ./lua-5.1-work3-loadlib3 -e 'print(loadlib("bundle.so","_luaopen_test"))'
function: 0x6d990

*** Forthcoming patch allows to load both:

osx$ ./lua-5.1-work3-loadlib4 -e 'print(loadlib("dylib.so","_luaopen_test"))'
function: 0x6d970

osx$ ./lua-5.1-work3-loadlib4 -e 'print(loadlib("bundle.so","_luaopen_test"))'
function: 0x6d990

Will send the new patch when I'm done with testing.

Bye,
     Mike