lua-users home
lua-l archive

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


Make sure that the main program (/usr/local/bin/lua?) has not been stripped of its global symbols, they're need to link the dynamic library into the interpreter. Use 'strip -x' if you want to reduce the size of the lua binary. Do not use 'install -s' or 'strip' without flags.

I've appended a Makefile I use to build a dynamic library. The magic incantations are stolen from luasocket Makefiles.

Hope this helps.



CFLAGS=-pedantic -fno-common -O2 -Wall
LDFLAGS=-bundle -undefined dynamic_lookup
CC=gcc
LD=export MACOSX_DEPLOYMENT_TARGET="10.4"; gcc

tlv.so: tlv.o
        $(LD) $(LDFLAGS) $< -o $@

tlv.o:  tlv.c

%.o:    %.c
        $(CC) $(CFLAGS) -c $< -o $@

On Jan 21, 2007, at 3:13 PM, Wesley Smith wrote:

I finally realized that the answer was not in lua conf, but in adding
-DLUA_USE_MACOSX to my "other C flags setting" (I'm doing the
compilation in Xcode).  When I tried to load a lib, I get this crash
log:

Link (dyld) error:

Symbol not found: _luaL_openlib
 Referenced from: /usr/local/lib/lua/5.1/mylib.so
 Expected in: dynamic lookup

Doing nm on the lib, I see

00000eb0 t __dyld_func_lookup
00000000 t __mh_bundle_header
        U _cos
00000ed0 t _l_cos
        U _luaL_openlib
        U _lua_pushnumber
        U _lua_tonumber
00000f10 T _luaopen_mylib
0000100c s _mylib
00001000 d dyld__mh_bundle_header
00001008 s dyld_func_lookup_pointer
00001004 s dyld_lazy_symbol_binding_entry_point
00000e80 t dyld_stub_binding_helper

The Lua library symbols are U (undefined) which I'd expect because the
module was compiled dynamically against liblua.a.  To give some
context, I'm building a Lua plugin to a software environment.  The
plugin has the Lua source compiled directly into it, so it contains
all of the symbols like "0001428c T _luaL_openlib".  Is there a way to
direct the lookup of this symbol into the binary of my external as
opposed to dyld crash because it can't find it in the mylib.so file?

thanks,
wes



--
Gé Weijers