AddThis Social Bookmark Button

Well, another UnsatisfiedLinkError, but worth knowing.Everything worked just fine in your machine and you take it to a different machine,BOOM , gone, "Can't find dependent libraries" , the reason is quite simple, lets talk about it.

A .dll file or an .so file is what you would create , which invokes some native method, but generally that is not it. There might have been more dependency between the native call, for which you would need the dependent dll or so file , not just yours. It worked on your machine because perhaps you have the dependent library in your library path , but the same file might not be available on the other machine. 

One of the solution I found to be like this. 

Load the dependent library first then then load your dll file.

In many cases the dependent file will not be available on clients machine, and another point is you may not have access to the client machines java library path , so you can't copy the dependent file in that path.

This solution is a good solution especially you want to distribute your library as well as the dependent library. ( Well, this seems to be a great idea, since clients are lazy to download the dependent libs, when you point them saying "download this software in order to proceed" they prefer not using your software 

the code snippet goes like this 

System.load("c:\\Users\\bullraider\\msvcr100d.dll");//path where you copied the dll in the client machine ;  this loads the dependent dll

System.load("c:\\Users\bullraider\\myDll.dll")//path where you copied the dll that you generated , goes into client, the actually dll you created
// then rest of your native method call

And you just saved a day of work.