Linux shared library for Lua
#1
I need someone who's more experienced in Linux than me.

I'd like to try making MCServer use the Lua library as a shared object, instead of linking it statically. However, I have no idea:
1, How to install the shared library
2, How to find the library's name

I have installed luarocks, which uses Lua and most definitely has the lua shared library somewhere, but how do I find it?

Thanks in advance.
Reply
Thanks given by:
#2
LuaRocks itself does not have a lua shared library packaged with it. Instead, it just uses the Lua CLI.

If you are looking for the lua library on a linux machine, you could simply do the following from the command line:
Code:
cd /usr
find . "lua" | grep "lua"
Its not the most efficient way to find it, but that should give you the name of every file in the usr folder which is relavant to lua. And then you just pick through and find any ".so" or ".a" files.

If you can only find .a files, then there isn't a shared library available for lua.
Reply
Thanks given by:
#3
I have found out how luarocks work on linux in the meantime - the luarocks' shared libraries use symbols exported from the lua executable itself. The problem for MCServer is that it doesn't export those lua symbols by default, and the only way I found to export the lua symbols is to export *all* symbols. That, however, makes the executable quite large, among other things. Anyone know of a better solution? I need something like __declspec(dllexport) in MSVC; I've tried the __attribute__((visibility("default"))) but it doesn't seem to work.
Reply
Thanks given by:
#4
I must be using a different version of luarocks than you, because there are no shared libs in the download I got. It just has scripts in it. Do you have a link to the version you are using?
Reply
Thanks given by:
#5
I used the default luarocks in my ubuntu distro, "apt-get install luarocks".
Then I proceeded to install luasocket through luarocks: "luarocks install luasocket".
This compiled the C support libraries for luasocket into a shared library "/usr/local/lib/lua/5.1/socket/core.so". I verified this by running "gdb lua", running the lua interpreter, issuing the "require 'socket'" command, Ctrl+C and back in gdb "info sharedlibrary".
The core.so library is linked so that it contains unresolved symbols from the lua runtime, then whatever executable loads that .so, the loader looks for those lua runtime functions in the executable and binds them to the .so.
Reply
Thanks given by:
#6
ok. That makes more sense. So its luasocket that has the .so, not luarocks.
Reply
Thanks given by:
#7
New question for the unix folks:
Does linking with the "-rdynamic" flag have any adverse effects, either to code speed, executable size or anything else, besides the point of exporting all functions (which is what we'd like)?

Special extra for the MacOS folks: is that option available in your build toolchain, too?

I can't find much on the issue since google decided to be people-friendly and treats "-rdynamic" the same as "dynamic" Sad
Reply
Thanks given by:
#8
I think you can use "-" to exclude things from the search. For example: "rdynamic -dynamic gcc"

I think you can even work with quotes.
Reply
Thanks given by:
#9
"rdynamic" is available on Mac OSX
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)