I've tried to build Lua 5.1.2 under Mac OS X 10.4 to use dlopen and
"make linux" almost works; there is only a small change in the link
flags. The correct macosx line in src/Makefile seems to be:
macosx:
$(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-lreadline"
(In other words, gcc does not like -Wl,-E. It actually does not mind -ldl.)
The question now was: how does one build a .so for Mac OS X in this case?
gcc -shared does not work.
I experimented with my lrandom and, adapting the instrucions at
this built an .so:
export MACOSX_DEPLOYMENT_TARGET=10.4
cc -o random.so -undefined dynamic_lookup lrandom.o
However, this .so does not work:
lua: error loading module 'random' from file './random.so':
dlsym(0x100dd0, luaopen_random): symbol not found
Sure enough, nm random.so shows that the _luaopen_random is the exported
symbol, not luaopen_random. So I added an "_" to LUA_POF in loadlib.c and
rebuilt Lua, but no luck:
dlsym(0x100dd0, _luaopen_random): symbol not found
So, what is the correct incantation?
--lhf