Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.lang.UnsatisfiedLinkError: Unable to load library

void_voidJan 22 2009 — edited Feb 25 2009
i am using netbeans 6.5 IDE on ubuntu
i have made the .so file for following c code
int add(int a,int b){
return(a+b);
}


and when i try to load this libarary(.so file ) i get the following exception
java.lang.UnsatisfiedLinkError: Unable to load library

my java code is


import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Platform;

/** Simple example of native library declaration and usage. */
public class HelloWorld {

public interface CLibrary extends Library {

CLibrary INSTANCE = (CLibrary)
Native.loadLibrary("temp",CLibrary.class);


int add(int a,int b);
}

public static void main(String[] args) {

int b = CLibrary.INSTANCE.add(2, 3);
System.out.println(b);
}



error

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'temp': libtemp.so: cannot open shared object file: No such file or directory
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:114)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:157)
at com.sun.jna.Library$Handler.<init>(Library.java:123)
at com.sun.jna.Native.loadLibrary(Native.java:260)
at com.sun.jna.Native.loadLibrary(Native.java:246)
at helloworljna.HelloWorld$CLibrary.<clinit>(HelloWorld.java:22)
at helloworljna.HelloWorld.main(HelloWorld.java:31)
Java Result: 1

i 've use following command to set path


export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib


pls tell how to solve
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 25 2009
Added on Jan 22 2009
11 comments
10,239 views