lzmq
lzmq copied to clipboard
lzmq doesn't use `pkg-config`
Fails to compile because it selects wrong ZMQ.
My system (Ubuntu 12.0) provides some old ZMQ headers in /usr/include
.
I installed some recent ZMQ version (via Homebrew). I have a pkg-config
in my PATH
which will find the correct ZMQ.
lzmq however doesn't seem to use pkg-config
and thus fails.
Using https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/lzmq-0.4.3-1.src.rock... switching to 'build' mode
Archive: v0.4.3.zip
72dbca09652bcc8f27a6ae2662f05d8220e25a2f
creating: lzmq-0.4.3/
...
gcc -O2 -fPIC -I/u/zeyer/code/torch/install/include -c src/lzmq.c -o src/lzmq.o -DLUAZMQ_USE_SEND_AS_BUF -DLUAZMQ_USE_TEMP_BUFFERS -DLUAZMQ_USE_ERR_TYPE_OBJECT -I/usr/include
src/lzmq.c:483:1: error: ‘ZMQ_EVENT_CONNECTED’ undeclared here (not in a function)
src/lzmq.c:484:1: error: ‘ZMQ_EVENT_CONNECT_DELAYED’ undeclared here (not in a function)
src/lzmq.c:485:1: error: ‘ZMQ_EVENT_CONNECT_RETRIED’ undeclared here (not in a function)
src/lzmq.c:487:1: error: ‘ZMQ_EVENT_LISTENING’ undeclared here (not in a function)
src/lzmq.c:488:1: error: ‘ZMQ_EVENT_BIND_FAILED’ undeclared here (not in a function)
src/lzmq.c:490:1: error: ‘ZMQ_EVENT_ACCEPTED’ undeclared here (not in a function)
src/lzmq.c:491:1: error: ‘ZMQ_EVENT_ACCEPT_FAILED’ undeclared here (not in a function)
src/lzmq.c:493:1: error: ‘ZMQ_EVENT_CLOSED’ undeclared here (not in a function)
src/lzmq.c:494:1: error: ‘ZMQ_EVENT_CLOSE_FAILED’ undeclared here (not in a function)
src/lzmq.c:495:1: error: ‘ZMQ_EVENT_DISCONNECTED’ undeclared here (not in a function)
src/lzmq.c:500:1: error: ‘ZMQ_EVENT_ALL’ undeclared here (not in a function)
Error: Failed installing dependency: https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/lzmq-0.4.3-1.src.rock - Build error: Failed compiling object src/lzmq.o
I support only luarocks
. How you try build it?
You can run luarocks install lzmq ZMQ_DIR=...
It's installed via luarocks
(via this script).
It's automatically installed as a dependency of iTorch.
I think it should automatically use pkg-config
to find the ZMG lib dir.
may be you can change script so you can pass ZMQ_DIR
/ZMQ_LIB_DIR
/ZMQ_INCLUDE_DIR
to luarocks
.
Problem here because luarocks find zmq.h
header (I suppose it from version ZMQ 2.X).
I am mostly works on windows so I use luarocks install lzmq ZMQ_DIR=%ZMQ_DIR%
.
I think better discuss whey how luarocks
search external deps on their issues tracker.
In google I found this
> Is there a way to have the "builtin" backend call pkg-config to
> determine compilation and link flags?
Unfortunately not, because it was designed to be cross-platform and
pkg-config is generally not available on Windows. But it's something
that should be available for Unix-only rocks in LuaRocks 3...
-- Hisham
Yes sure, but I shouldn't do that because it should do that automatically.
The normal solution is use pkg-config
which is exactly for this purpose to automatically find the path for libs.
E.g.:
% pkg-config --cflags libzmq
-I/work/asr2/zeyer/linuxbrew/Cellar/zeromq/4.1.4/include
Ah, I see, that is supposed to be fixed in LuaRocks itself?
I found the post you referred to here.
I'm a bit confused. I searched around and it seems as other Lua libs are using pkg-config
just fine. E.g. here (sample output). It seems that package uses a Makefile.
It can be done only in luarocks
not in rockspec.
Now luarocks does not support this so you have to do this by hand.
I am not sure either luarocks can use ZMQ_DIR
var from environment.
I can suggest open issues on https://github.com/keplerproject/luarocks/issues
Have you seen https://github.com/deepakjois/luaharfbuzz ? It uses pkg-config
via the rockspec.
They uses makefile
I think it will quite hard make makefile
which will works on MSVC/MinGW/Linux/OSX ...
Why you can not just install lzmq by hand before you run install script
luarocks install lzmq CFLAGS="..." LIBFLAG="...."
and run your rest installation.
I can do that but I think that it should be done automatically. And I'm still not sure where this automatism should be done. If LuaRocks will not handle it, then the package itself should do it. In a Makefile, you can have sections for each OS.
Btw., I tried that (luarocks install lzmq CFLAGS="-I/work/asr2/zeyer/linuxbrew/Cellar/zeromq/4.1.4/include" LIBFLAG="-L/work/asr2/zeyer/linuxbrew/Cellar/zeromq/4.1.4/lib -lzmq"
) and it fails:
...
gcc -I/work/asr2/zeyer/linuxbrew/Cellar/zeromq/4.1.4/include -I/u/zeyer/code/torch/install/include -c src/zpoller.c -o src/zpoller.o -DLUAZMQ_USE_SEND_AS_BUF -DLUAZMQ_USE_TEMP_BUFFERS -DLUAZMQ_USE_ERR_TYPE_OBJECT -I/usr/include
gcc -I/work/asr2/zeyer/linuxbrew/Cellar/zeromq/4.1.4/include -I/u/zeyer/code/torch/install/include -c src/zsocket.c -o src/zsocket.o -DLUAZMQ_USE_SEND_AS_BUF -DLUAZMQ_USE_TEMP_BUFFERS -DLUAZMQ_USE_ERR_TYPE_OBJECT -I/usr/include
gcc -L/work/asr2/zeyer/linuxbrew/Cellar/zeromq/4.1.4/lib -lzmq -o lzmq.so -L/u/zeyer/code/torch/install/lib src/lzmq.o src/lzutils.o src/poller.o src/zcontext.o src/zerror.o src/zmsg.o src/zpoller.o src/zsocket.o -L/usr/lib -Wl,-rpath,/usr/lib: -lzmq
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
src/lzmq.o: In function `luazmq_pass':
lzmq.c:(.text+0x127): undefined reference to `lua_pushboolean'
src/lzmq.o: In function `luazmq_fail_str':
lzmq.c:(.text+0x22c): undefined reference to `lua_pushnil'
...
you also should point to lua header path Also nmake has different syntaksis other than gnu make
The "undefined reference to main" is there because "-shared" is missing from LIBFLAG
.