Neopallium / lua-zmq

Lua zeromq2 binding
http://github.com/Neopallium/lua-zmq
MIT License
153 stars 36 forks source link

luajit #18

Closed dvv closed 13 years ago

dvv commented 13 years ago

Hi!

I've local installation of luajit, and managed to build lua-zmq by 1) symlinking libluajit.so to liblua.so and 2) running LUA_DIR=/path/of/luajit/src cmake ... When I try to require('zmq') i get undefined symbol _ZdlPv error.

Wonder, is it luajit or libzmq who requires this symbol an how to solve the problem.

TIA, --Vladimir

Neopallium commented 13 years ago

hmm, I have always compiled Lua C module using the standard Lua VM and they work just fine under LuaJIT.

What system are you on? What version of 0MQ? What version of LuaJIT?

symbol _ZdlPv seems to be needed by libzmq and is provided by libstdc++.so. Maybe there is something wrong with how libzmq was compiled on your system.

See if the output from: ldd /usr/lib/libzmq.so Includes libstdc++.so

dvv commented 13 years ago

Yeah, I coped with that by prefixing with LD_PRELOAD=/path/to/libstdc++.so. Then it starts to want uuid. luajit 2.0.0-beta8, zmq 2.1.9, debian 6.0.

On another system ubuntu 11.04 the same stuff builds cleanly and ldd zmq.so does show deps on stdc++, pthread, zmq.

Will keep investingating

Neopallium commented 13 years ago

uuid is also needed by libzmq. It sounds like a problem with how libzmq was built.

dvv commented 13 years ago

Is it ever possible to run this module in ffi mode if it is linked against static zmq version -- libzmq.a? Right now for such build I get libzmq.so: cannot open shared object ...

Neopallium commented 13 years ago

I don't recommend doing that, there isn't going to be any performance benefit.

It is possible but you will need to change the LDFLAGS of the host executable (that is the host application that is linked with libluajit) so that the public symbols from libzmq.a are accessible from dlopen().

Also you need to replace the "ffi_load { ..... }," from lua-zmq/zmq.nobj.lua (lines 33-36) with: ffi_source [[ local C = ffi.C ]],

If you want to completely statically build LuaJIT and link it against libzmq.a and lua-zmq, then you will still need to make a dynamic executable and link against libdl.so (that is the only way for LuaJIT's FFI feature to dynamically access the public symbols).

dvv commented 13 years ago

I see. Thanks for exhaustive explanation. Thanks god cmake allowed me to tune the building process w/o patching anything. As rationale to such approach I mean root-less access to a system, when there's noway to sudo make install anything.

Best regards, --Vladimir