通过JNI调用SO动态链接库的有关问题

通过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$ 


------解决方案--------------------
*(void **)(&_THUserID) = dlsym(aslib, "_THUserID");
这个地方会找不到符号,最好是先判断它是否为空~~
是不是没有使用extern "C" 声明函数, 可以用nm看看so里面是不是没有这个符号存在
------解决方案--------------------
自己看《程序员自我修养》,不用重复发帖