JAVA调用SO文件报UnsatisfiedLinkError
今天使用JNI接口,JAVA调用C编写的SO文件,但是屡次报这个错误:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Comm.getMsgOut()Ljava/lang/String;
at Comm.getMsgOut(Native Method)
at Comm.main(Comm.java:9)
在CentOS系统下生成libComm.so文件,命令是:
gcc -fpic -shared -I /usr/java/jdk1.8.0_25/include -I /usr/java/jdk1.8.0_25/include/linux Comm.c -o libComm.so
//Comm.h
/* DO NOT EDIT THIS FILE - it is machine generated */
#include
/* Header for class com_test_read_Comm */
#ifndef _Included_com_test_read_Comm
#define _Included_com_test_read_Comm
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_test_read_Comm
* Method: getMsgOut
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_c