5

I've installed 0MQ on a VM running CentOS and I have a C-based application happily working with it. However, I'm unable to get the Java application to work via JZMQ bindings. Here's the error I get:

java -Djava.library.path=/usr/local/lib -jar AidApps.jar receive localhost:9007
Starting the receiver application.
Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/local/lib/libjzmq.so.0.0.0: libzmq.so.1: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1750)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1675)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at org.zeromq.ZMQ.<clinit>(ZMQ.java:34)
at com.ijet.Receiver.main(Receiver.java:9)
at com.ijet.Main.main(Main.java:13)

I don't get any errors during installation of either 0MQ or JZMQ. I tried copying all libraries into /usr/local/lib but that didn't solve anything. Any ideas? This works on my Mac (so I know the JAR works), but not on the Linux box.

j0k
  • 22,600
  • 28
  • 79
  • 90
Yuri Brigance
  • 542
  • 4
  • 13
  • 2
    run `ldd /usr/local/lib/libjzmq.so.0.0.0` and give us the output – J-16 SDiZ Jun 20 '12 at 21:52
  • Here's the output `ldd /usr/local/lib/libjzmq.so.0.0.0` `linux-vdso.so.1 => (0x00007fffa1f31000)` `libzmq.so.1 => not found` `libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f4f7a17c000)` `libm.so.6 => /lib64/libm.so.6 (0x00007f4f79ef8000)` `libc.so.6 => /lib64/libc.so.6 (0x00007f4f79b68000)` `libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f4f79951000)` `/lib64/ld-linux-x86-64.so.2 (0x00000033ca600000)` – Yuri Brigance Jun 20 '12 at 22:08
  • 2
    does `libzmq.so.1` exist? Try `file libzmq.so.1`, is it a 64-bit ELF? – J-16 SDiZ Jun 20 '12 at 22:34
  • When I run that command I get the following: `libzmq.so.1: symbolic link to `libzmq.so.1.0.0'` – Yuri Brigance Jun 20 '12 at 22:36
  • 1
    Does `libzmq.so.1.0.0` exist ? Is the path in `/etc/ld.so.conf` ? How about `file libzmq.so.1.0.0` ? Does `ldconfig -n /usr/local/lib` help? – J-16 SDiZ Jun 20 '12 at 23:12
  • @J-16SDiZ, your suggestion worked! I added a zmq.conf file to `/etc/ld.so.conf.d/` which contains the path to `/usr/local/lib`, then I ran `ldconfig` and now I'm able to run the JAR without throwing an exception. Thanks a bunch for all your help! – Yuri Brigance Jun 21 '12 at 16:29

2 Answers2

10

Steps to fix this problem (credit goes to to J16-SDiZ):

1) cp /root/zeromq-2.1.11/src/.libs/*.* /usr/local/lib
2) nano /etc/ld.so.conf.d/zmq.conf
3) Add line /usr/local/lib and save
4) ldconfig
5) Verify by running ldconfig -v | grep zmq
6) Run the JAR java -Djava.library.path=/usr/local/lib/ -jar AidApps.jar receive localhost:9007

Note that the -Djava.library.path still needs to be specified, point it to the jzmq.jar file.

Yuri Brigance
  • 542
  • 4
  • 13
7

This is because ld.so cannot resolve your libzmq.so.1.0.0.

Add the path /usr/local/lib to /etc/ld.so.config and run ldconfig to rebuild the cache.

J-16 SDiZ
  • 26,473
  • 4
  • 65
  • 84