2013-03-25 45 views
0

我以前的工作JNI lib下, 出于某种原因(我不知道有任何curcial改变),我不能再使用它,因为我得到以下错误:不满意链接功能工作之前

Exception in thread "main" java.lang.UnsatisfiedLinkError: de.ifi.lmu.sommerd.ftsserver.jni.IndexJNI.loadIndex(Ljava/lang/String;)V at de.ifi.lmu.sommerd.ftsserver.jni.IndexJNI.loadIndex(Native Method)

因此,这里是我的测试设置:

package de.ifi.lmu.sommerd.ftsserver.jni; 

public class IndexJNI { 

    static { 
     System.load("/home/XXX/workspace/IndexJNI/resources/newLib.so"); 
     System.out.println("Loading library worked"); 
     IndexJNI.loadIndex(""); 
    } 


    public static native void loadIndex(String indexName); 
} 

而这里.H的相关部分和.c文件:

/* DO NOT EDIT THIS FILE - it is machine generated */ 
#include <jni.h> 
/* Header for class de_ifi_lmu_sommerd_ftsserver_jni_IndexJNI */ 

#ifndef _Included_de_ifi_lmu_sommerd_ftsserver_jni_IndexJNI 
#define _Included_de_ifi_lmu_sommerd_ftsserver_jni_IndexJNI 
#ifdef __cplusplus 
extern "C" { 
#endif 
/* 
* Class:  de_ifi_lmu_sommerd_ftsserver_jni_IndexJNI 
* Method: loadIndex 
* Signature: (Ljava/lang/String;)V 
*/ 
JNIEXPORT void JNICALL Java_de_ifi_lmu_sommerd_ftsserver_jni_IndexJNI_loadIndex 
    (JNIEnv *, jobject, jstring); 

#ifdef __cplusplus 
} 
#endif 
#endif 

.c文件

JNIEXPORT void JNICALL Java_de_ifi_lmu_sommerd_ftsserver_jni_IndexJNI_loadIndex 
    (JNIEnv * env, jclass jc, jstring indexName) { 
... 
} 

,这是我的makefile:

test_gcc_lib: run_queries.o 
    g++ -shared -fPIC run_queries.o SSA.a -o newLib.so 
+0

run_queries.o里面有什么? – 2013-03-25 21:16:04

回答

0

所以,问题是,我改变了调用静态, 所以现在签字不再正确。 我只需要将jobject改为jclass。