lua-users home
lua-l archive

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


Hi,

PA wrote:
> Mike Pall provided the following incantation to compile modules on Mac 
> OS X:
> 
> local CompileCommand = "gcc -O2 -fno-common -c -o"
> local LinkCommand = "gcc -bundle -undefined dynamic_lookup -o"
> 
> Works like a charm.

Yes, but on Lua 5.1 only!

The original posting asked about Lua 5.0.2. But this one doesn't have any
support for Mac OS X. You need to patch it. Look into src/lib/loadlib.c
at the bottom. However this patch requires you to compile your modules
as dylibs (and not as bundles).

Peter Colson wrote:
> So far I keep getting a Nil return from loadlib.

The second return value should tell you what went wrong. Try:

lua -e 'print(loadlib("xyz.so", "_luaopen_xyz"))'

For Lua 5.0.2 "xyz.so" has to be in the current dir.

With Lua 5.1 you should use require("xyz") and put the module into the
proper path ( /usr/local/lib/lua/5.1/xyz.so ).

Asko Kauppi wrote:
> Shouldn't there be a "sample" dynamic module included with Lua core tgz 
> now.

Yes, a hello world would suffice. But the Makefile that needs to
accompany it is the real problem. There are about a dozen common
variations for creating a shared library, depending on the OS and
the toolchain.

Bye,
     Mike