Reputation: 3434
I have an application which is using one native library libclient.so. which is dependent on another .so file.
I tried setting LD_LIBRARY_PATH using command line on linux 32 bit system:
export LD_LIBRARY_PATH=/home/usb:${LD_LIBRARY_PATH}
It is setting path as:
tushar@tushar-desktop:~$ echo $LD_LIBRARY_PATH
/home/usb:/home/tushar/workspace/MinutiaeApp/resources:
But when I try to run my code I get null in LD_LIBRARY_PATH and I think because of which I am getting Unsatisfied Link Error.
Here is my testing code:
String lib = "libclient.so";
String ld_lib_path = System.getenv("LD_LIBRARY_PATH");
System.out.println("***LD_LIBRARY_PATH ***"+ ld_lib_path); // **GIVING NULL**
String[] paths = ld_lib_path.split(":");
for(int i=0; i<paths.length; i++) {
String p = paths[i];
File x = new File(p, lib);
System.out.println("***Path name *****" + i + " : "+ x.getAbsolutePath());
if (x.exists()) {
System.out.println("Exist");
System.load(x.getAbsolutePath());
break;
}
}
Actual Code:
System.load("/home/usb/libclient.so"); // **HERE I am getting Unsatisfied Link Error**
UPDATE: I have set the LD_LIBRARY_PATH in the VM arguments and I am getting path name on running follwing line in my java code. So path is set.
String ld = System.getProperty("LD_LIBRARY_PATH");
Now the problem is that when I try to load the libgrfingerjava.so using System.load("/home/arun/libgrfinger.so")
I still get Unsatisfied Link Error.
I tried loading some other .so file and I am able to do that. I don't know why I am getting error only on libgrfingerjava.so
.
I am integrating Griaule Finger SDK 2009 into my finger reading application.
Upvotes: 1
Views: 1904
Reputation: 17422
Are you running your program in the same shell?
You need to run your application in the same shell were you are setting LD_LIBRARY_PATH, it doesn't work if you have are modifying an environment in a "window console" and running your programm in Eclipse or another window.
UPDATE
If you are using Eclipse, in your menu, go to Project --> Properties --> Run/Debug Settings, then choose the configuration you're using and edit it, you will see this window:
Select the tab "Environment" and click on "New" you'll know what to do for the rest.
Upvotes: 1
Reputation: 3462
you should try to run this program from the same terminal from where you have set LD_LIBRARY_PATH.
Upvotes: 1