Accessing Cuda through JNI from Java on Mac


I have been trying to invoke Cuda code thru JNI from java on mac.

This is what I did.

  1. Declared a simple native method, and called System.loadLibrary in java
  2. Compiled java file, created header file
  3. included header file in the cuda code, implemented the native method
  4. compiled cuda code through nvcc, used g++ -fPIC -o to create output fle (just like what the built in make file does)
  5. used g++ -shared to create jnilib

I have included all the libraries that the make-file pointed to and also included the jni.h location.

When I run the java code, I get this

Invalid memory access of location 79df8f3c eip=8fe17dc7
Segmentation fault

Please see that I do not get unsatisfied link error. When I call a different library name in java (something that does not exist), I get unsatisfied link error.

What could be the problem?

Thanks in advance.