3

I'm trying to embed zeroMQ in my app, I followed this guideline to install ZMQ, so till here everything works fine. I have this line of code in my app:

ZMQ.Context m_context = ZMQ.context(1);

but above line of code raise below exception:

Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/libjzmq-812339378390536247.lib: libzmq.so.3: cannot open shared object file: No such file or directory
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1939)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1864)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1825)
    at java.lang.Runtime.load0(Runtime.java:792)
    at java.lang.System.load(System.java:1059)
    at org.zeromq.EmbeddedLibraryTools.loadEmbeddedLibrary(EmbeddedLibraryTools.java:136)
    at org.zeromq.EmbeddedLibraryTools.<clinit>(EmbeddedLibraryTools.java:22)
    at org.zeromq.ZMQ.<clinit>(ZMQ.java:38)
    at com.castaclip.verticals.Messenger.<init>(Messenger.java:125)
    at com.castaclip.verticals.PushMessenger.<init>(PushMessenger.java:30)
    at com.castaclip.verticals.pushserver.App.setup(App.java:60)
    at com.castaclip.verticals.pushserver.App.main(App.java:41)

The error is exactly pointing to this line.

P.S: its a little bit difficult to fully explain this question.. if you have any question plz let me know. thanks.

Community
  • 1
  • 1
tokhi
  • 21,044
  • 23
  • 95
  • 105
  • So you built core zmq, libzmq, and jzmq without errors? Did you confirm the `.so` library files were generated? When you run java, did you set up `LD_LIBRARY_PATH` so your program can find the library files? – raffian Jun 24 '13 at 18:56
  • Yeah, all the `.so` library files are generated and the library path is also looks fine: `~$ echo $LD_LIBRARY_PATH /usr/local/lib` – tokhi Jun 25 '13 at 08:32

3 Answers3

16

If you've successfully built libzmq and jzmq in that order, I would run:

$ sudo ldconfig

to update the system library cache. Then I would check to see if LD_LIBRARY_PATH is defined like Raffian mentioned, or set your library path explicitly to something like:

$ java -Djava.library.path=/usr/lib:/usr/local/lib
Trevor Bernard
  • 992
  • 10
  • 13
  • I have already done that: `~$ echo $LD_LIBRARY_PATH /usr/local/lib` – tokhi Jun 25 '13 at 08:36
  • @stsd Log out, then log back in. Sometimes `ldconfig` doesn't sync properly, so it needs a kick in the boot. http://stackoverflow.com/questions/12935623/error-installing-zeromq/16522807#16522807 – raffian Jun 25 '13 at 13:25
  • 1
    @Trevor Bernard Thank you, you made my day! :-) ldconfig solved this problem for me. – Sergiy Sokolenko Mar 14 '15 at 18:35
1

Finally I tried to figure out the problem. I was using zeromq-2.1.10 and this was part of the problem.

So I installed zeromq-3.2.3 from the source and problem resolved.

tokhi
  • 21,044
  • 23
  • 95
  • 105
0

I encountered a mystifying instance of this message when I:

# java -Djava.library.path=/usr/hf/zmq/lib/ -cp '/usr/hf/lib/*:.' com.zmqtest.MA
Exception in thread "main"
java.lang.UnsatisfiedLinkError: /usr/hf/zmq/lib/libjzmq.so:
libzmq.so.3: cannot open shared object file: No such file or directory

which was fixed with a solution that makes no sense at all to me:

# LD_LIBRARY_PATH=/usr/hf/zmq/lib/ java -Djava.library.path=/usr/hf/zmq/lib/ -cp '/usr/hf/lib/*:.' com.zmqtest.MA

wierd.

DJC
  • 3,243
  • 3
  • 27
  • 31
  • I had the same issue. It worked too when setting the LD_LIBRARY_PATH variable, although I was using -Djava.library.path with the same value. JZQM is a bit annoying because it really wants you to have your library in /usr/local/lib, so you can't really use multiple versions on the same machine. ZMQ doesn't exhibit this problem: by defining the right parameters when building the RPM, you can have multiple versions co-located on one machine. – jplandrain May 29 '15 at 08:11