Trouble Loading JNI Shared Object File: Unsatisfied Link Error
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sean_McClenathan
Posted On:   Tuesday, March 24, 2009 04:18 PM

OS: Cent OS 5.2 / Ubuntu 8.04 I have some C++ classes successfully wrapped through SWIG to a Shared Object file. The library loaded and ran correctly on the command line when I tested it, I gave it to my coworker and she was able to get it to load and run locally in eclipse, but when we try to deploy it as a WAR file to the Cent OS box we get a Unsatisfied Link Error when the server tries to load the Library. I am unsure if it is that the library is built incorrectly or because we're linking it incorrectly. If it's being incorrectly linked what is the correct way to link an .so file from within the WAR, if it's the case that the library is incorrectly built how should it be fixed? How we load the library:    More>>

OS: Cent OS 5.2 / Ubuntu 8.04

I have some C++ classes successfully wrapped through SWIG to a Shared Object file. The library loaded and ran correctly on the command line when I tested it, I gave it to my coworker and she was able to get it to load and run locally in eclipse, but when we try to deploy it as a WAR file to the Cent OS box we get a Unsatisfied Link Error when the server tries to load the Library. I am unsure if it is that the library is built incorrectly or because we're linking it incorrectly. If it's being incorrectly linked what is the correct way to link an .so file from within the WAR, if it's the case that the library is incorrectly built how should it be fixed?



How we load the library:

			
try
{
//System.load("/home/mathbio/ecc/Simulation.so"); //how we load on the desktop
System.load("/WEB-INF/classes/edu/unomaha/mathbio/JNIHandler/Simulation.so");//the path of the .so file within the WAR file
}catch(Exception e)
{
e.printStackTrace();
}


The swig specification file for Simulation.so:

			
%module CC
%include "cpointer.i"
%include "std_string.i"
using namespace std;
typedef std::string string;
%pointer_functions(int, intp);
%{
#include "Simulation.h"
%}
%include "Simulation.h"


The swig command I used to build the library is:

			
swig -java -package edu.unomaha.mathbio.JNIHandler -c++ Simulation.i



I'd appreciate any insight into the problem.    <<Less

Re: Trouble Loading JNI Shared Object File: Unsatisfied Link Error

Posted By:   shiladitya_sircar  
Posted On:   Saturday, April 18, 2009 09:42 PM

This clearly is a problem with your load library path not being found by the servlet container.


System.loadLibrary() uses short name and no path prefix or extensions i.e. so, dll etc. You just need to ensure java.library.path is set up either programmatically by setting system property or start the JVM with D option.


System.loadLibrary("Simulation"); should be preferred .. if you must do System.Load() .. then make sure your validate your assumptions by:



File file = new File("/WEB-INF/classes/edu/unomaha/mathbio/JNIHandler/Simulation.so")
If(file.Exists(())
System.load( file.toString() );
Else
System.out.println("Simulation.so is not found in library path");
About | Sitemap | Contact