lua-users home
lua-l archive

Re: require .so and call may cause abort trap at free()

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



On Jan 9, 2012 7:09 PM, "Artur Galyamov" <artur-pub@yandex.ru> wrote:
>
> 10.01.2012, 04:00, "Ignacio Burgueño" <ignaciob@inconcertcc.com>:
>>
>> 2012年1月9日 Artur Galyamov <artur-pub@yandex.ru>
>>>
>>> Hi,
>>>
>>>
>>> ...
>>> 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?
>>
>>  
>> ...
>>>
>>>
>>> $ cc test.c -shared -o test.so -llua -lm
>>>
>> I think that is the problem. You shouldn't link with -llua in your .so.
>
>  
> I just look at how /usr/local/bin/lua is built:
> gcc -o lua   lua.o liblua.a -lm -lreadline
>  
> I should not mix static and dynamic linking, right?
> How do I then `require` external libraries with default Lua installation?  
> Should I compile lua* to use liblua.so?
> Thanks!
You shouldn't link to Lua in your runtime, but instead have it look for Lua symbols in the global namespace, that way no matter how the executable gets Lua (static link, dynamic, luajit) it gets the necessary symbols.


AltStyle によって変換されたページ (->オリジナル) /