通过JNI调用SO动态链接库的问题
这是我的JNI
JNIEXPORT jint JNICALL Java_com_callTHUserID(JNIEnv *env, jobject obj,jint model){
void *imglib;
int (*_THUserID)(int);
int result;
aslib = dlopen("./libVerifyThorCR.so", RTLD_LAZY);//打开.SO 成功
if ( aslib != NULL ) {
*(void **)(&_THUserID) = dlsym(aslib, "_THUserID");
printf("bbbbbbbbbbbbbbbbb\n");//可以打印。
//在此调用C++生成的SO(通常是第三方动态库)
result = _THUserID(model);//为什么调用SO的函数_THUserID 报错呢,而且这个日志的错误不明显啊
} else {
printf("THUserID 00000000000000\n");
}
return result;
}
以下是报错信息。
cdp@ubuntu:~/workspace/myjava/bin$ java -Djava.library.path=. com.cdp.Hello
bbbbbbbbbbbbbbbbb
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x0000000000000000, pid=4738, tid=139650285664000
#
# JRE version: 6.0_38-b04
# Java VM: Java HotSpot(TM) 64-Bit Server VM (20.13-b02 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C 0x0000000000000000 float+0x2224c000
#
# An error report file with more information is saved as:
# /home/cdp/workspace/myjava/bin/hs_err_pid4738.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
已放弃 (核心已转储)
cdp@ubuntu:~/workspace/myjava/bin$
void *imglib;
int (*_FreeTHFaceID)(int);
int imghandle;
imglib = dlopen("./libFaceVerifyTHOCR.so", RTLD_LAZY);
if ( imglib != NULL ) {
*(void **)(&_FreeTHFaceID) = dlsym(imglib, "_FreeTHFaceID");
printf("bbbbbbbbbbbbbbbbb\n");
imghandle = _FreeTHFaceID(frMode);
} else {
printf("FreeTHFaceID 00000000000000\n");
}
pcd@ubuntu:~/workspace/myjava/bin$ java -Djava.library.path=. com.pcd.Hello
bbbbbbbbbbbbbbbbb
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x0000000000000000, pid=4738, tid=139650285664000
#
# JRE version: 6.0_38-b04
# Java VM: Java HotSpot(TM) 64-Bit Server VM (20.13-b02 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C 0x0000000000000000 float+0x2224c000
#
# An error report file with more information is saved as:
# /home/pcd/workspace/myjava/bin/hs_err_pid4738.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
已放弃 (核心已转储)
pcd@ubuntu:~/workspace/myjava/bin$
JNIEXPORT jint JNICALL Java_com_callTHUserID(JNIEnv *env, jobject obj,jint model){
void *imglib;
int (*_THUserID)(int);
int result;
aslib = dlopen("./libVerifyThorCR.so", RTLD_LAZY);//打开.SO 成功
if ( aslib != NULL ) {
*(void **)(&_THUserID) = dlsym(aslib, "_THUserID");
printf("bbbbbbbbbbbbbbbbb\n");//可以打印。
//在此调用C++生成的SO(通常是第三方动态库)
result = _THUserID(model);//为什么调用SO的函数_THUserID 报错呢,而且这个日志的错误不明显啊
} else {
printf("THUserID 00000000000000\n");
}
return result;
}
以下是报错信息。
cdp@ubuntu:~/workspace/myjava/bin$ java -Djava.library.path=. com.cdp.Hello
bbbbbbbbbbbbbbbbb
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x0000000000000000, pid=4738, tid=139650285664000
#
# JRE version: 6.0_38-b04
# Java VM: Java HotSpot(TM) 64-Bit Server VM (20.13-b02 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C 0x0000000000000000 float+0x2224c000
#
# An error report file with more information is saved as:
# /home/cdp/workspace/myjava/bin/hs_err_pid4738.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
已放弃 (核心已转储)
cdp@ubuntu:~/workspace/myjava/bin$
void *imglib;
int (*_FreeTHFaceID)(int);
int imghandle;
imglib = dlopen("./libFaceVerifyTHOCR.so", RTLD_LAZY);
if ( imglib != NULL ) {
*(void **)(&_FreeTHFaceID) = dlsym(imglib, "_FreeTHFaceID");
printf("bbbbbbbbbbbbbbbbb\n");
imghandle = _FreeTHFaceID(frMode);
} else {
printf("FreeTHFaceID 00000000000000\n");
}
pcd@ubuntu:~/workspace/myjava/bin$ java -Djava.library.path=. com.pcd.Hello
bbbbbbbbbbbbbbbbb
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x0000000000000000, pid=4738, tid=139650285664000
#
# JRE version: 6.0_38-b04
# Java VM: Java HotSpot(TM) 64-Bit Server VM (20.13-b02 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C 0x0000000000000000 float+0x2224c000
#
# An error report file with more information is saved as:
# /home/pcd/workspace/myjava/bin/hs_err_pid4738.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
已放弃 (核心已转储)
pcd@ubuntu:~/workspace/myjava/bin$
...全文
相关推荐
linux-java调用c语言编译的so动态库-jni例子-简单计算器
在linux下,java调用c语言编译的*.so动态链接库的小例子.是一个简单计算器的例子.在java中传操作数和操作符,由C来计算,把结果传过来给java.
java调用c++生成so库
linux 环境下java调c++生成的so库,对应博客地址: http://blog.csdn.net/woniu211111/article/details/78041868
jni_example:springboot环境下java调用c程序生成动态链接库(.so文件),并调用(基于JNI,Ubuntu)
jni_example springboot环境下java调用c程序生成动态链接库(.so文件),并调用(基于JNI,Ubuntu) 文档
美图动态链接库和JNI类文件
美图动态链接库和JNI类文件,可用于创建自己的美图软件。
android调用第三方so库
android调用已编译的第三方.so库。只是一个简单的例子。


