Library reports undefined symbol: clock_gettime while loading
Closed this issue · 2 comments
By some reason, and on my machine, the library builds successfully but can't be loaded into many installed Lua/LuaJIT intepreters (the major exception is Lua Torch). Not sure if it is a bug either on Luarocks or on my environment variables. I've tried to clear/reset my environment variables, but it doesn't work as well. Inspecting the compilation process from Luarocks I obtain the following:
gcc -O2 -fPIC -I/usr/local/include -c src/chronos.c -o src/chronos.o
gcc -shared -o chronos.so -L/usr/local/lib src/chronos.o
But, as you already know, the default system libraries are stored under /usr prefix, not /usr/local prefix. My own workaround was to manually compile with (after unpacking the rock/zip code):
gcc -O2 -fPIC -I/usr/include -c src/chronos.c -o src/chronos.o
gcc -shared -o chronos.so -L/usr/lib -lrt src/chronos.o
And then, copy that chronos.so into the respective chronos.so previously installed (into the associated Luarocks' tree for sure), forcing overwriting (indeed). Now it works fine, but I thought that issue could be relevant here, cause other fellows could ran in the same sort of problem.
Perhaps, that kind of problem could be solved using some pkg-config/.configure stuff to automatically detect the dependencies (in the case, the library rt if my mind is still working in such late night). Thanks in advance, guy!
The complete error, although not much helpful, is here:
lua: error loading module 'chronos' from file '/home/troll/.luarocks/lib/lua/5.3/chronos.so':
/home/troll/.luarocks/lib/lua/5.3/chronos.so: undefined symbol: clock_gettime
stack traceback:
[C]: in ?
[C]: in function 'require'
[C]: in ?
OK, thank you by this reply! I'm looking forward for that patch!