Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shogun install - Java compilation error (UnsatisfiedLinkError) #4226

Closed
ypic opened this issue Apr 3, 2018 · 8 comments
Closed

Shogun install - Java compilation error (UnsatisfiedLinkError) #4226

ypic opened this issue Apr 3, 2018 · 8 comments

Comments

@ypic
Copy link

ypic commented Apr 3, 2018

Hi there,
I just installed Shogun (Mac OS X - 10.13.3) and tried to compile my first Java Class using the example from the website.
Nothing special to report from the install itself, activated the Java Interface and that's pretty much it.

I'm using Eclipse to run my Java project and I get the following error
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.shogun.shogunJNI.new_RealFeatures__SWIG_0(I)J
at org.shogun.shogunJNI.new_RealFeatures__SWIG_0(Native Method)
at org.shogun.RealFeatures.(RealFeatures.java:42)
at MklRegression.main(MklRegression.java:10)

From my research in many places over the Web I understood it may be a problem from the java.library.path or environment variable DYLD_LIBRARY_PATH.

Just to add that after the install I ran the command export DYLD_LIBRARY_PATH="usr/local/lib/libshogun.dylib:$DYLD_LIBRARY_PATH" as recommended on the Shogun website (for Mac OS users) and I also tried to change the java.library.path in Eclipse but the error still remains so I have to say I'm now really stuck.
Any help would be appreciated chaps :) !

Cheers

Y

@vigsterkr
Copy link
Member

@ypic honestly i have never used shogun from eclipse, i can provide you a CLI for how to use shogun from JVM

@ypic
Copy link
Author

ypic commented Apr 3, 2018

@vigsterkr could be good yep, better then nothing ;) thanks for the prompt reply

@vigsterkr
Copy link
Member

ok so here's an example from our buildbot:
/usr/bin/java "-Xmx1024m" "-cp" "/usr/share/java/jblas.jar:/home/buildslave/deb3_-_interfaces/build/build/src/interfaces/java/shogun.jar:/home/buildslave/deb3_-_interfaces/build/build/examples/meta/java:/home/buildslave/deb3_-_interfaces/build/build/examples/meta/java/binary" "-Djava.library.path=/home/buildslave/deb3_-_interfaces/build/build/src/interfaces/java" "averaged_perceptron"

basically you need to have the shogun.jar and jblas.jar in the classpath and have the libshogun.dylib (or .so if you are under linux) in java.library.path

@vigsterkr
Copy link
Member

you can actually test this yourself whether it works or not if you enable BUILD_META_EXAMPLES cmake flag

@ypic
Copy link
Author

ypic commented Apr 4, 2018

I tried with one of the examples (multiple_kernel_learning):
/usr/bin/java -Xmx1024m -verbose -cp /Users/home/Downloads/jblas-1.2.4.jar:/Users/home/shogun/build/src/interfaces/java/shogun.jar:/usr/local/Cellar/shogun/6.1.3/share/shogun/examples/java/regression -Djava.library.path=/usr/local/lib multiple_kernel_learning

  • I have the binary in the same folder .../examples/java/regression
  • libshogun.dylib is in folder "/usr/local/lib"

And I get the following
java.lang.UnsatisfiedLinkError: org.shogun.shogunJNI.init_shogun_with_defaults()V
at org.shogun.shogunJNI.init_shogun_with_defaults(Native Method)
at org.shogun.shogun.init_shogun_with_defaults(shogun.java:39)
at multiple_kernel_learning.main(multiple_kernel_learning.java:22)

@ypic
Copy link
Author

ypic commented Apr 4, 2018

Just to add, I've also tried to change the environmental variable $DYLD_LIBRARY_PATH but no changes unfortunately :(

@karlnapf
Copy link
Member

karlnapf commented Apr 4, 2018

I googled a bit and found
http://www.swig.org/Doc2.0/Java.html#Java_dynamic_linking_problems

It seems that the Shogun java lib is not visible to your java executable.

what happens if you run the tests locally using cmake, i.e.
ctest -R generated_java-binary-multiple_kernel_learning -V

@ypic
Copy link
Author

ypic commented Apr 4, 2018

@karlnapf and @vigsterkr thanks for your help Gentlemen. It is working now ! I have other small problems (only related to the jvm itself but no big deal)
Actually I got confused initially with the repository I had to point to as I was pointing on the folder with the *.dylib till the beginning (following instructions on the website). Then I changed it to the folder with the *.JNILIB and got it working now. Just in case some readers may want to run it with Eclipse I could also run it with Eclipse properly , changing the path in Project => Properties => Java Build Path => JRE System Library, expand it and put the path in Native Library Location.

Thanks again for your help guys

Y

@ypic ypic closed this as completed Apr 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants