lua-users home
lua-l archive

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


It was thus said that the Great Artur Galyamov once stated:
> Hi,
> 
> I require external .so module and call a function from it. If it creates a
> table, lua_close() fails with abort trap somewhere in collector code. I'm
> stuck with it, can someone please test this on similar configuration?
> 
> test.c was reduced from bigger source.
> OSX 10.6.8, Lua 5.2.0 release (tar xf, make macosx, make install) in /usr/local
> 
> cc, gcc and clang all give same results. I tried it with 5.1.4, still same results..
> 
> If I do main() && luaL_newstate() && luaopen_test() && luaL_dostring() in test.c, it's all ok.
> It seems that problem is in test.so itself… Is my test.so build process okay?
> 
> Thanks in advance.
> 
> -- Artur
> 
> $ cc test.c -shared -o test.so -llua -lm

  I know when making shared object with GCC, you need to add the -fPIC
option to the command line.  This tells GCC to produce position independent
code.  So, to compile your code:

% gcc -shared -fPIC -o test.so

  The Lua interpreter has been compiled such that all global functions are
visible to loadable modules so you don't need to compile against the math
and Lua libraries (unlike a standalone program embedding Lua).  

  -spc