Mac OS X: java.lang.UnsatisfiedLinkError: no jzmq in java.library.path #29

Closed
felixrabe opened this Issue Feb 18, 2011 · 11 comments

Comments

Projects
None yet
4 participants
@felixrabe

I've tried repeatedly installing jzmq on Mac OS X. Whatever I do, I hit a brick wall with this exception:
java.lang.UnsatisfiedLinkError: no jzmq in java.library.path

I have successfully installed (pkg-config and) libzmq and libjzmq into /usr/local/lib from today's github master branches. For jzmq, I did:
./autogen.sh && ./configure --with-zeromq=/usr/local/lib && make && sudo make install
But setting java.library.path in any way, even manually at the start of my Java code, or even setting LD_LIBRARY_PATH, has no effect at all - I keep getting that UnsatisfiedLinkError.

I would very much like to use jzmq for my projects, as I already have done a client and server implementation in Python and want to connect it to the Java world. (For the curious: http://gentlefn.github.com/gentle-tp-da92/)

Versions:

  • libzmq and jzmq: current github master
  • Mac OS X: 10.6.6, up-to-date
  • Java (most recent JDK provided by Apple): 1.6.0_22-b04-307-10M3261
@felixrabe

This comment has been minimized.

Show comment
Hide comment
@felixrabe

felixrabe Feb 18, 2011

I've also tried:
mvn clean install
But both the included tests also fail with UnsatisfiedLinkError.

I've also tried:
mvn clean install
But both the included tests also fail with UnsatisfiedLinkError.

@felixrabe

This comment has been minimized.

Show comment
Hide comment
@felixrabe

felixrabe Feb 18, 2011

mvn -version -> 2.2.1

mvn -version -> 2.2.1

@gonzus

This comment has been minimized.

Show comment
Hide comment
@gonzus

gonzus Feb 21, 2011

Contributor

I don't use (nor have I ever used) OSX. But let's assume it is just another flavor of Linux (I mean, Unix). The jzmq JAR (zmq.jar) requires two other components to work properly: the native 0MQ shared library (libzmq.so), the same thing used by any regular C/C++ program, and a bridge shared library (jzmq.so) that allows the Java 0MQ classes to interface with the native 0MQ shared library.

With that out of the way, I would try the following:

  1. Put zmq.jar, jzmq.so and libzmq.so in a place that you are POSITIVE will make things work. I am thinking of /usr/local/lib or even /usr/lib. Make sure a minimal test program actually does work.
  2. Once that works, move things to your CWD and try the same minimal program there.
  3. One that works, move things to wherever you really want to put them, and make that work.

Apologies if these instructions seem too basic; this is really the way I would approach diagnosing this. Please let me know how it goes.

Contributor

gonzus commented Feb 21, 2011

I don't use (nor have I ever used) OSX. But let's assume it is just another flavor of Linux (I mean, Unix). The jzmq JAR (zmq.jar) requires two other components to work properly: the native 0MQ shared library (libzmq.so), the same thing used by any regular C/C++ program, and a bridge shared library (jzmq.so) that allows the Java 0MQ classes to interface with the native 0MQ shared library.

With that out of the way, I would try the following:

  1. Put zmq.jar, jzmq.so and libzmq.so in a place that you are POSITIVE will make things work. I am thinking of /usr/local/lib or even /usr/lib. Make sure a minimal test program actually does work.
  2. Once that works, move things to your CWD and try the same minimal program there.
  3. One that works, move things to wherever you really want to put them, and make that work.

Apologies if these instructions seem too basic; this is really the way I would approach diagnosing this. Please let me know how it goes.

@abelaska

This comment has been minimized.

Show comment
Hide comment
Contributor

abelaska commented Feb 23, 2011

@gonzus

This comment has been minimized.

Show comment
Hide comment
@gonzus

gonzus Feb 23, 2011

Contributor

Felix, have you had any progress? I am trying to close issues that have already been solved.

Contributor

gonzus commented Feb 23, 2011

Felix, have you had any progress? I am trying to close issues that have already been solved.

@felixrabe

This comment has been minimized.

Show comment
Hide comment
@felixrabe

felixrabe Feb 25, 2011

gonzus: Thanks for responding! I will report back in the next few days with more details, following your checklist. Please give me another week or so, I've already been trying three times over the course of a month to get this to work without success.

abelaska: I think I've looked at pretty much everything that Google gave me for "jzmq osx", but I'll have another look at that link to check that I haven't forgotten anything. I think I've got the pkg-config and Java Development Kit parts right though.

I will install it all again and come back with more detailed notes.

gonzus: Thanks for responding! I will report back in the next few days with more details, following your checklist. Please give me another week or so, I've already been trying three times over the course of a month to get this to work without success.

abelaska: I think I've looked at pretty much everything that Google gave me for "jzmq osx", but I'll have another look at that link to check that I haven't forgotten anything. I think I've got the pkg-config and Java Development Kit parts right though.

I will install it all again and come back with more detailed notes.

@lt-schmidt-jr

This comment has been minimized.

Show comment
Hide comment
@lt-schmidt-jr

lt-schmidt-jr Mar 10, 2011

Mac OSX uses DYLD_LIBRARY_PATH instead of unix LD_LIBRARY_PATH

Mac OSX uses DYLD_LIBRARY_PATH instead of unix LD_LIBRARY_PATH

@felixrabe

This comment has been minimized.

Show comment
Hide comment
@felixrabe

felixrabe Mar 14, 2011

I finally got it to work today! This is how, step-by-step:

I'm using MacPorts and am on Mac OS X 10.6.6. I have installed a current Xcode (and thus gcc and that stuff), as well as pkg-config using MacPorts.

First, I get and build zeromq2:

git clone git://github.com/zeromq/zeromq2.git
cd zeromq2  # current commit is 2970d6c30b1f57e9a75d46982378b103899bddbc
./autogen.sh && ./configure && make && sudo make install && echo ":: ALL OK ::"
cd ..
ls -al /usr/local/lib/libzmq.*

Output of 'ls -al':

-rwxr-xr-x  1 root  wheel   348920 Mar 14 13:14 /usr/local/lib/libzmq.1.dylib
-rw-r--r--  1 root  wheel  6306760 Mar 14 13:14 /usr/local/lib/libzmq.a
lrwxr-xr-x  1 root  wheel       14 Mar 14 13:14 /usr/local/lib/libzmq.dylib -> libzmq.1.dylib
-rwxr-xr-x  1 root  wheel      912 Mar 14 13:14 /usr/local/lib/libzmq.la

Then, I get and build jzmq:

git clone git://github.com/zeromq/jzmq.git
cd jzmq  # current commit is 522d7474effe8c96dfaece51e739eda9189bad45
export JAVA_HOME="$(/usr/libexec/java_home)"  # /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
./autogen.sh && ./configure && make && sudo make install && echo ":: ALL OK ::"
cd ..
ls -al /usr/local/lib/*jzmq* /usr/local/share/java/*zmq*

Output of 'ls -al':

-rwxr-xr-x  1 root  wheel   27600 Mar 14 13:42 /usr/local/lib/libjzmq.0.dylib
-rw-r--r--  1 root  wheel  279448 Mar 14 13:42 /usr/local/lib/libjzmq.a
lrwxr-xr-x  1 root  wheel      15 Mar 14 13:42 /usr/local/lib/libjzmq.dylib -> libjzmq.0.dylib
-rwxr-xr-x  1 root  wheel     943 Mar 14 13:42 /usr/local/lib/libjzmq.la
-rw-r--r--  1 root  wheel   10268 Mar 14 13:42 /usr/local/share/java/zmq.jar

Then, I build and run HelloWorldClient.java:

javac -classpath /usr/local/share/java/zmq.jar HelloWorldClient.java
java -classpath .:/usr/local/share/java/zmq.jar -Djava.library.path=/usr/local/lib HelloWorldClient

This client runs, and I can now e.g. start a server or communicate interactively using a Python console with PyZMQ.

I finally got it to work today! This is how, step-by-step:

I'm using MacPorts and am on Mac OS X 10.6.6. I have installed a current Xcode (and thus gcc and that stuff), as well as pkg-config using MacPorts.

First, I get and build zeromq2:

git clone git://github.com/zeromq/zeromq2.git
cd zeromq2  # current commit is 2970d6c30b1f57e9a75d46982378b103899bddbc
./autogen.sh && ./configure && make && sudo make install && echo ":: ALL OK ::"
cd ..
ls -al /usr/local/lib/libzmq.*

Output of 'ls -al':

-rwxr-xr-x  1 root  wheel   348920 Mar 14 13:14 /usr/local/lib/libzmq.1.dylib
-rw-r--r--  1 root  wheel  6306760 Mar 14 13:14 /usr/local/lib/libzmq.a
lrwxr-xr-x  1 root  wheel       14 Mar 14 13:14 /usr/local/lib/libzmq.dylib -> libzmq.1.dylib
-rwxr-xr-x  1 root  wheel      912 Mar 14 13:14 /usr/local/lib/libzmq.la

Then, I get and build jzmq:

git clone git://github.com/zeromq/jzmq.git
cd jzmq  # current commit is 522d7474effe8c96dfaece51e739eda9189bad45
export JAVA_HOME="$(/usr/libexec/java_home)"  # /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
./autogen.sh && ./configure && make && sudo make install && echo ":: ALL OK ::"
cd ..
ls -al /usr/local/lib/*jzmq* /usr/local/share/java/*zmq*

Output of 'ls -al':

-rwxr-xr-x  1 root  wheel   27600 Mar 14 13:42 /usr/local/lib/libjzmq.0.dylib
-rw-r--r--  1 root  wheel  279448 Mar 14 13:42 /usr/local/lib/libjzmq.a
lrwxr-xr-x  1 root  wheel      15 Mar 14 13:42 /usr/local/lib/libjzmq.dylib -> libjzmq.0.dylib
-rwxr-xr-x  1 root  wheel     943 Mar 14 13:42 /usr/local/lib/libjzmq.la
-rw-r--r--  1 root  wheel   10268 Mar 14 13:42 /usr/local/share/java/zmq.jar

Then, I build and run HelloWorldClient.java:

javac -classpath /usr/local/share/java/zmq.jar HelloWorldClient.java
java -classpath .:/usr/local/share/java/zmq.jar -Djava.library.path=/usr/local/lib HelloWorldClient

This client runs, and I can now e.g. start a server or communicate interactively using a Python console with PyZMQ.

@gonzus

This comment has been minimized.

Show comment
Hide comment
@gonzus

gonzus Mar 14, 2011

Contributor

Felix, this is great news. Perhaps you could add this documentation to the proper section in http://www.zeromq.org/docs:tuning-zeromq (I think that is the proper place). Thanks for the update.

Contributor

gonzus commented Mar 14, 2011

Felix, this is great news. Perhaps you could add this documentation to the proper section in http://www.zeromq.org/docs:tuning-zeromq (I think that is the proper place). Thanks for the update.

@felixrabe

This comment has been minimized.

Show comment
Hide comment
@felixrabe

felixrabe Mar 14, 2011

Gonzus, thanks for the feedback. Feel free to add a link to this issue there, as I don't have an account there.

By the way, HelloWorldClient.java mentioned above is https://github.com/imatix/zguide/blob/609b4255d87287a42932392db1d50256c1b878ae/examples/Java/hwclient.java

Gonzus, thanks for the feedback. Feel free to add a link to this issue there, as I don't have an account there.

By the way, HelloWorldClient.java mentioned above is https://github.com/imatix/zguide/blob/609b4255d87287a42932392db1d50256c1b878ae/examples/Java/hwclient.java

@lt-schmidt-jr

This comment has been minimized.

Show comment
Hide comment
@lt-schmidt-jr

lt-schmidt-jr Mar 14, 2011

As a note:
On Mac, I found that I prefer using Homebrew over MacPorts, as many of the ports are stale.
Cheers.

As a note:
On Mac, I found that I prefer using Homebrew over MacPorts, as many of the ports are stale.
Cheers.

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment