lua-users home
lua-l archive

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


Make sure to link with the flag '-bundle'. It adds the required tables for symbol lookup.

This works for me:

$ gcc -pedantic -std=c89 -dynamic -O2 -Wall -DVERSION=\"1.5\" -c sha256.c -o sha256.o
$ export MACOSX_DEPLOYMENT_TARGET="10.4"; gcc -bundle -undefined dynamic_lookup sha256.o -o sha256.so



On Apr 3, 2007, at 4:23 PM, Luiz Henrique de Figueiredo wrote:

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



--
Gé Weijers