About .SO files on Linux

Hello, a simple question. Where I have to put the .SO files of JCuda?

I suposed is that the cause that I get the following error message:

Error while loading native library "JCudaDriver-linux-x86_64" with base name "JCudaDriver"
Operating system name: Linux
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/libJCudaDriver-linux-x86_64.so'
        at jcuda.LibUtils.loadLibraryResource(LibUtils.java:144)
        at jcuda.LibUtils.loadLibrary(LibUtils.java:80)
        at jcuda.driver.JCudaDriver.<clinit>(JCudaDriver.java:192)
        at cudaraul.JCudaVectorAdd.main(JCudaVectorAdd.java:26)
Stack trace from the attempt to load the library as a file:
java.lang.UnsatisfiedLinkError: no JCudaDriver-linux-x86_64 in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1738)
        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.<clinit>(JCudaDriver.java:192)
        at cudaraul.JCudaVectorAdd.main(JCudaVectorAdd.java:26)

Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load the native library
        at jcuda.LibUtils.loadLibrary(LibUtils.java:122)
        at jcuda.driver.JCudaDriver.<clinit>(JCudaDriver.java:192)
        at cudaraul.JCudaVectorAdd.main(JCudaVectorAdd.java:26)
Java Result: 1


Usually, the files have to be located …

  • either in the root directory of your project
  • or in a directory that is visible via the java.library.path
  • or in a directory that is visible as the LD_LIBRARY_PATH (on linux, I’m not 100% sure about that…)

The first one should be the easiest. Did you try the Basic Test as decribed on the Tutorial site, http://jcuda.org/tutorial/TutorialIndex.html#BasicTest ?


Thanks for the answer. The first option not works. Sincerely, i don’t know which directory it’s visible via java.library.path.

I placed the .so files of jcuda in /usr/local/cuda/lib64 and /usr/local/cuda/lib
and I modified the variable $PATH

bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/cuda/bin:/usr/local/cuda/lib64: No such file or directory

But I get the same error (also with the basic test).

I tried to compile the basic test as you mentioned in http://forum.byte-welt.de/showthread.php?t=2972&langid=2
and it works, but when I tried to run the program, I got the following error message:

raul@RAULMINT ~/dir $ javac -cp ".:jcuda-0.4.0-beta1.jar" JCudaRuntimeTest.java
raul@RAULMINT ~/dir $ java -cp ".:jcuda-0.4.0-beta1.jar" JCudaRuntimeTest
Exception in thread "main" java.lang.NoClassDefFoundError: JCudaRuntimeTest (wrong name: cudaraul/JCudaRuntimeTest)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: JCudaRuntimeTest.  Program will exit.

The library path can be specified as a command line argument when starting Java, like
java -Djava.library.path “./yourLibraryPath” -cp “.:jcuda-0.4.0-beta1.jar” JCudaRuntimeTest
but again, this should not be required.

I’m not so familiar with Linux and the directory structure on linux, so I’m not sure what causes the “No such file or directory” message on the bash. But it should also not be necessary to copy JCuda libraries into any directory of the toolkit.

The preference for now should be to get the “Basic Test” running. The line
java.lang.NoClassDefFoundError: JCudaRuntimeTest (wrong name: **cudaraul/**JCudaRuntimeTest)
indicates that it does not find the main class. Did you put the class into a package, i.e. did you add a package declaration like
package cudaraul;
? This should NOT be necessary for the first test, which only should show whether CUDA is working in general.