Can't find the dependent library for mavenized JCUDA in Eclipse - java

I am trying to setup mavenized JCUDA for a project that I am working on and am running into issues with telling java where to locate the library files.
Setting up and getting maven to build the .jar and .dll files has worked fine, I can see the correctly named .dll files in project\target\lib and I am setting my native library location to this folder.
The error I get when trying to run one of the programs from JCUDA JCublasSample.java (www.jcuda.org/samples/JCublasSample.java) is:
Creating input data... Performing Sgemm with Java... Performing Sgemm
with JCublas...
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not
load the native library.
Error while loading native library "JCublas-windows-x86_64" with base
name "JCublas" Operating system name: Windows 7 Architecture :
amd64 Architecture bit size: 64
Stack trace from the attempt to load the library as a resource:
java.lang.NullPointerException: No resource found with name
'/lib/JCublas-windows-x86_64.dll'
at jcuda.LibUtils.loadLibraryResource(LibUtils.java:149) at
jcuda.LibUtils.loadLibrary(LibUtils.java:83) at
jcuda.jcublas.JCublas.initialize(JCublas.java:93) at
jcuda.jcublas.JCublas.(JCublas.java:81) at
JCublasSample.sgemmJCublas(JCublasSample.java:64) at
JCublasSample.testSgemm(JCublasSample.java:49) at
JCublasSample.main(JCublasSample.java:25)
Stack trace from the attempt to load the library as a file:
java.lang.UnsatisfiedLinkError:
C:\Users\kristoffer.bernhem\git\SMlocalizer\target\lib\JCublas-windows-x86_64.dll:
Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method) at
java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941) at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857) at
java.lang.Runtime.loadLibrary0(Runtime.java:870) at
java.lang.System.loadLibrary(System.java:1122) at
jcuda.LibUtils.loadLibrary(LibUtils.java:94) at
jcuda.jcublas.JCublas.initialize(JCublas.java:93) at
jcuda.jcublas.JCublas.(JCublas.java:81) at
JCublasSample.sgemmJCublas(JCublasSample.java:64) at
JCublasSample.testSgemm(JCublasSample.java:49) at
JCublasSample.main(JCublasSample.java:25) at
jcuda.LibUtils.loadLibrary(LibUtils.java:128) at
jcuda.jcublas.JCublas.initialize(JCublas.java:93) at
jcuda.jcublas.JCublas.(JCublas.java:81) at
JCublasSample.sgemmJCublas(JCublasSample.java:64) at
JCublasSample.testSgemm(JCublasSample.java:49) at
JCublasSample.main(JCublasSample.java:25)
As explained by Guenther, the problem lies in supporting .dll files that are lacking. How would I go about sorting this error out?
This is being run in windows 7 (64bit) and run with JDK1.8.0_91.

Related

JNI library missing

I am trying to run a test file InspectVM from libguestfs library inorder to have accesss to a disk image in windows. However, I have the following errors on my console
run:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no guestfs_jni in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at madjava.com.redhat.et.libguestfs.GuestFS.<clinit>(GuestFS.java:51)
at madjava.examples.InspectVM.main(InspectVM.java:30)
C:\Users\CyberSOFONET\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)#
I searched allover the internet and find that I should set java.libraly.path pointing to location of the guestfs_jni. my major problem is that I do not have any file with that name guestfs_jni. Do I need to make one myself or can I find it somewhere. any kind of help is appriciated. am a newbie in JNI so I dont have much imformation on it
You're looking for a file called guestfs_jni.dll. Usually the native library comes with the jar file.
From http://libguestfs.org/guestfs-java.3.html:
Libguestfs for Java is a Java Native Interface (JNI) extension, supplied in three parts: libguestfs.jar, libguestfs-VERSION.jar, libguestfs_jni.so, libguestfs.so
So the distribution comes with libguest_jni.so which ist for Linux and not for Windows. IIRC, there is no libguestfs for Windows. So you would first have to find out if it is even possible to compile libguestfs using Cygwin and if yes build it yourself.
If you're on Windows 10 you could try installing libguestfs and a Java runtime for the Linux subsystem and run inside the subsystem.

Exception in thread "Thread-60" java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path

Attempting to build sikuli-slides-1.5.0 with the command "mvn clean install", I am getting the above referenced stack trace. I am using Windows 7 and have attempted the instructions I have come across for various solutions proposed on here to no avail. My Path and CLASSPATH variables for both user and system defined variables include:
"C:\opencv\build\x64\vc10\bin"
and I have restarted my machine multiple times.
In addition, I have added javacv.jar, javacv.windows-x86.jar, javacv.windows-x86_64.jar to my project's build path and have javacv-0.9.jar in my pom.xml. I have also included javacpp-0.9.jar in my pom as well. I can visually see all of the above referenced jars on my build path and can import the jniopencv_core into any of my classes. Any assistance would be greatly appreciated. While executing the JUnit test AutomationExecutorExceptionTest.java, the test fails and creates an orphaned java.exe process that must be manually shut down.
The full stack trace is listed below.
Exception in thread "Thread-60" java.lang.UnsatisfiedLinkError: no jniopencv_core in >java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:535)
at org.bytedeco.javacpp.Loader.load(Loader.java:410)
at org.bytedeco.javacpp.Loader.load(Loader.java:353)
at org.bytedeco.javacpp.opencv_core.(opencv_core.java:10)
at org.bytedeco.javacpp.helper.opencv_core$AbstractIplImage.create(openc
v_core.java:909)
at org.bytedeco.javacpp.helper.opencv_core$AbstractIplImage.createFrom(o
pencv_core.java:999)
at org.bytedeco.javacpp.helper.opencv_core$AbstractIplImage.createFrom(o
pencv_core.java:971)
at org.bytedeco.javacpp.helper.opencv_core$AbstractIplImage.createFrom(o
pencv_core.java:968)
at org.sikuli.core.cv.ImagePreprocessor.createGrayscale(ImagePreprocesso
r.java:43)
at org.sikuli.core.search.TemplateMatcher.findMatchesByGrayscaleAtOrigin
alResolution(TemplateMatcher.java:71)
at org.sikuli.api.ImageTarget.getUnorderedMatches(ImageTarget.java:127)
at org.sikuli.api.DefaultTarget.doFindAll(DefaultTarget.java:128)
at org.sikuli.api.DefaultScreenRegion.findAll(DefaultScreenRegion.java:7
4)
at org.sikuli.slides.api.sikuli.CrossSearchStrategy.testHypotheses(Cross
SearchStrategy.java:85)
at org.sikuli.slides.api.sikuli.CrossSearchStrategy.perform(CrossSearchS
trategy.java:39)
at org.sikuli.slides.api.sikuli.ContextImageTarget.doFindAll(ContextImag
eTarget.java:122)
at org.sikuli.api.DefaultScreenRegion._find(DefaultScreenRegion.java:88)
at org.sikuli.api.DefaultScreenRegion.find(DefaultScreenRegion.java:80)
at org.sikuli.slides.api.actions.TargetAction.execute(TargetAction.java:
26)
at org.sikuli.slides.api.actions.RetryAction.execute(RetryAction.java:51
)
at org.sikuli.slides.api.actions.ParallelAction$Worker.run(ParallelActio
n.java:35)
at java.lang.Thread.run(Thread.java:745)
Your stack trace contains the following line:
Exception in thread "Thread-60" java.lang.UnsatisfiedLinkError: no jniopencv_cor e in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
Notice the space between jniopencv_cor and e?
One of your configuration files contain a space where it shouldn't.
The directions are highly confusing for the javacv files. The issue was that I had to actually explode the contents of the jar file and expose the DLLs in the directory. The instructions packaged with the jars of javacv instructed me to simply place the binaries on the classpath.
I had the same problem and I solved it by adding the following dependency in my Maven project for Sikuli Slides 1.5.1:
GroupId: org.bytedeco.javacpp-presets
AritfactId: opencv
Version: 2.4.9-0.9
Type: jar
Classifier: windows-x86_64
In my case I was using Windows 7 64-bit. After adding this dependency I was able to successfully build Sikuli Slides.

java.lang.UnsatisfiedLinkError: no so in java.library.path

When i'm trying to load the .so file from the Java, i'm getting error like this.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no yeslib.so in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1681)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at com.rct.micros.util.GetCustClass.getScratchCode(GetCustClass.java:76)
at com.rct.micros.util.GetCustClass.main(GetCustClass.java:39)
I have tried System.load(absoulte path) and System.loadLibrary(sofilename). Both are giving the same error. When i copy this so file into usr/lib/jvm package, it is working..
can anyone help how to get this solved using Java. i'm running on linux box.
It's possible that the library is on your path, but it can't be loaded for some other reason.
A trick I've used to debug problems like this is to run java -Xrunsofilename
-Xrun is the JVM option to load JVMPI libraries (the old profiling interface). If it succeeds, it will load the library and complain that it's not an agent library. But if it fails (hopefully!) it will print an error message. This is usually a more descriptive error message than what you get from the UnsatisfiedLinkError.

Can't find/load swt-gtk

I'm trying to run an internal web browser using JWebBrowser. When I run the application in Netbeans environment it works perfectly. However, when I build the project and run the jar file I'm getting the following error:
NativeSwing[1]: Exception in thread "main" java.lang.UnsatisfiedLinkError: Could
not load SWT library. Reasons:
NativeSwing[1]: no swt-gtk-3721 in java.library.path
NativeSwing[1]: no swt-gtk in java.library.path
NativeSwing[1]: Can't load library: C:\Users\CCS.swt\lib\win32\amd64\swt-gtk-3721.dll
NativeSwing[1]: Can't load library: C:\Users\CCS.swt\lib\win32\amd64\swt-gtk.dll
I'm including the following libraries to the project:
DJNativeSwing.jar
DJNativeSwing-SWT.jar
DJNativeSwing-SWTAPI.jar
DJNativeSwing-SWTCore.jar
MozillaInterfaces-1.8.1.3.jar
swt.jar (version 3.7M5 for 64 bits.)
jna_WindowUtils.jar
jna-3.2.4.jar
and they're referenced by Manifest.MF by this way
Class-Path: lib/DJNativeSwing-SWT.jar lib/DJNativeSwing-SWTAPI.jar lib
/DJNativeSwing-SWTCore.jar lib/MozillaInterfaces-1.8.1.3.jar lib/DJNa
tiveSwing.jar lib/swt.jar lib/jna-3.2.4.jar lib/jna_WindowUtils.jar
What am I doing wrong?
Thank you.
You need to specify the java.library.path in the java command and aim it at the path to your .dll files. For example,
java -Djava.library.path=lib -cp ...
Ok, I found the solution. The problem was about the dll generation. I was using 3.7m5 version, I downloaded a previous version (3.7) and the application ran properly.
Thank you for your help.
Regards.

JCuda error: undefined symbol: Pointer_buffer

I am trying to run a JCuda example in Debian Linux (32bit). Since there is no binaries available on JCuda website for Linux x86, I've compliled the libraries. Now I'm trying yo run the DeviceQuery example but I get the following errors:
Error while loading native library "JCudaDriver-linux-x86" with base name "JCudaDriver"
Operating system name: Linux
Architecture : i386
Architecture bit size: 32
Stack trace from the attempt to load the library as a resource:
java.lang.NullPointerException: No resource found with name '/lib/libJCudaDriver-linux-x86.so'
at jcuda.LibUtils.loadLibraryResource(LibUtils.java:144)
at jcuda.LibUtils.loadLibrary(LibUtils.java:80)
at jcuda.driver.JCudaDriver.(JCudaDriver.java:192)
at jcudatest.JCudaTest.main(JCudaTest.java:29)
Stack trace from the attempt to load the library as a file:
java.lang.UnsatisfiedLinkError: /home/rui/Downloads/JCuda-All-0.4.0-beta1-src/JCudaDriverJNI/lib/libJCudaDriver-linux-x86.so: /home/rui/Downloads/JCuda-All-0.4.0-beta1-src/JCudaDriverJNI/lib/libJCudaDriver-linux-x86.so: undefined symbol: Pointer_buffer
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1732)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at jcuda.LibUtils.loadLibrary(LibUtils.java:90)
at jcuda.driver.JCudaDriver.(JCudaDriver.java:192)
at jcudatest.JCudaTest.main(JCudaTest.java:29)
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load the native library
at jcuda.LibUtils.loadLibrary(LibUtils.java:122)
at jcuda.driver.JCudaDriver.(JCudaDriver.java:192)
at jcudatest.JCudaTest.main(JCudaTest.java:29)
Java Result: 1
I belive the error here is related to that undefined symbol Pointer_buffer, since I created symbolic links on /lib and this folder is on PATH variables (I can see it resolving the symboling link to /home/rui/Downloads/JCuda-All-0.4.0-beta1-src/JCudaDriverJNI/lib/libJCudaDriver-linux-x86.so like it was supposed). Everything is working with Cuda as well, since I can compile and run Cuda examples. Cuda version is 4.0.17 and JCuda 0.4.0-beta1 (from JCuda website I can see Version 0.4.0-beta1. These libraries have been compiled for CUDA 4.0 (build 17) so I think I don't have any incompatibility here as well).
I am setting up my project on Netbeans, and I've included the source files present on JcudaJava folder. Do I need to include the cpp and hpp file from JCudaDriverJNI and JCudaRuntimeJNI folders (I never worked with JNI before, don't really know what I need to include).
Thanks in advance,
Rui
An "undefined symbol" means that a definition for the symbol (variable, function) was not found. JCuda defines Pointer_buffer in CommonJNI/PointerUtils.cpp so there must have been some problem including PointerUtils.o in the .so. Were there any errors when you compiled?

Categories