(HelP)got an unsatisfiedlinkerror when using the jni
I am now working on a jni project and get the unsatisfiedlinkerror. But after I browse this forum, I do not get any useful information.
my java code:
//
package graphmining.cliquer;
public class WClique {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
WClique wc = new WClique();
wc.buildGraph(4);
}
static
{
System.loadLibrary("WClique");
}
public native static void buildGraph(int vertexNumber);
public native static void addEdge(int i, int j);
public native static void setEdgeNumber(int e);
public native static int isAboveThreshold(int threshold);
}
I use "javah -jni graphmining.cliquer. WClique" get the WClique.h file.
// begin of WClique.h file;
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class graphmining_cliquer_WClique */
#ifndef _Included_graphmining_cliquer_WClique
#define _Included_graphmining_cliquer_WClique
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class:graphmining_cliquer_WClique
* Method:buildGraph
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_graphmining_cliquer_WClique_buildGraph
(JNIEnv *, jclass, jint);
/*
* Class:graphmining_cliquer_WClique
* Method:addEdge
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_graphmining_cliquer_WClique_addEdge
(JNIEnv *, jclass, jint, jint);
/*
* Class:graphmining_cliquer_WClique
* Method:setEdgeNumber
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_graphmining_cliquer_WClique_setEdgeNumber
(JNIEnv *, jclass, jint);
/*
* Class:graphmining_cliquer_WClique
* Method:isAboveThreshold
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_graphmining_cliquer_WClique_isAboveThreshold
(JNIEnv *, jclass, jint);
#ifdef __cplusplus
}
#endif
#endif
// end the wclique.h file
Then, I build the .c file.
//the .c file
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
#include "WClique.h"
/* Header for class graphmining_cliquer_WClique */
#ifndef _Included_graphmining_cliquer_WClique
#define _Included_graphmining_cliquer_WClique
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class:graphmining_cliquer_WClique
* Method:buildGraph
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_graphmining_cliquer_WClique_buildGraph
(JNIEnv * env, jclass cl, jint i){
int z = i;
}
/*
* Class:graphmining_cliquer_WClique
* Method:addEdge
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_graphmining_cliquer_WClique_addEdge
(JNIEnv * env, jclass cl, jint i, jint j){
int zz = i;
int zz
}
/*
* Class:graphmining_cliquer_WClique
* Method:setEdgeNumber
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_graphmining_cliquer_WClique_setEdgeNumber
(JNIEnv * env, jclass cl, jint j){
}
/*
* Class:graphmining_cliquer_WClique
* Method:isAboveThreshold
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_graphmining_cliquer_WClique_isAboveThreshold
(JNIEnv * env, jclass cl, jint j){
return 0;
}
#ifdef __cplusplus
}
#endif
#endif
//end the WClique. c file
My program is running in a linux pc.
And I use the commands
"gcc -I"/java/include" -I"/java/include/linux" -o WClique.o -c WClique.c
gcc -shared -o WClique.so WClique.o "
to get the .so file.
Then, I call the .so file from the original java file. However, it always returns the "unsatisfiedlinkerror". Note that I have used the correct library path and function name. I do not know what's wrong with it. Any one can help it?

