diff --git a/arpack/src/main/native/jni.c b/arpack/src/main/native/jni.c index 35f5a865..5d335450 100644 --- a/arpack/src/main/native/jni.c +++ b/arpack/src/main/native/jni.c @@ -2124,11 +2124,9 @@ jboolean get_system_property(JNIEnv *env, jstring key, jstring def, jstring *res return TRUE; } -static void *libhandle; - jboolean load_symbols(void) { #define LOAD_SYMBOL(name) \ - name = dlsym(libhandle, #name); \ + name = dlsym(NULL, #name); \ if (!name) { \ return FALSE; \ } @@ -2196,6 +2194,8 @@ jboolean load_symbols(void) { return TRUE; } +static void *libhandle; + jint JNI_OnLoad(JavaVM *vm, UNUSED void *reserved) { JNIEnv *env; if ((*vm)->GetEnv(vm, (void**)&env, JNI_VERSION_1_6) != JNI_OK) { @@ -2270,7 +2270,7 @@ jint JNI_OnLoad(JavaVM *vm, UNUSED void *reserved) { return -1; } - libhandle = dlopen(name, RTLD_LAZY); + libhandle = dlopen(name, RTLD_LAZY | RTLD_GLOBAL); if (!libhandle) { return -1; } diff --git a/blas/src/main/native/jni.c b/blas/src/main/native/jni.c index 157b0c58..52f1c400 100644 --- a/blas/src/main/native/jni.c +++ b/blas/src/main/native/jni.c @@ -1974,11 +1974,9 @@ jboolean get_system_property(JNIEnv *env, jstring key, jstring def, jstring *res return TRUE; } -static void *libhandle; - jboolean load_symbols(void) { #define LOAD_SYMBOL(name) \ - name = dlsym(libhandle, #name); \ + name = dlsym(NULL, #name); \ if (!name) { \ return FALSE; \ } @@ -2055,6 +2053,8 @@ jboolean load_symbols(void) { return TRUE; } +static void *libhandle; + jint JNI_OnLoad(JavaVM *vm, UNUSED void *reserved) { JNIEnv *env; if ((*vm)->GetEnv(vm, (void**)&env, JNI_VERSION_1_6) != JNI_OK) { @@ -2129,7 +2129,7 @@ jint JNI_OnLoad(JavaVM *vm, UNUSED void *reserved) { return -1; } - libhandle = dlopen(name, RTLD_LAZY); + libhandle = dlopen(name, RTLD_LAZY | RTLD_GLOBAL); if (!libhandle) { return -1; } diff --git a/generator.py b/generator.py index a0e95500..8a1eac3f 100644 --- a/generator.py +++ b/generator.py @@ -370,11 +370,9 @@ def __init__(self, pkg, libname, *routines): print("}") print() # Print symbols loading - print("static void *libhandle;") - print() print("jboolean load_symbols(void) {") print("#define LOAD_SYMBOL(name) \\") - print(" name = dlsym(libhandle, #name); \\") + print(" name = dlsym(NULL, #name); \\") print(" if (!name) { \\") print(" return FALSE; \\") print(" }") @@ -387,6 +385,8 @@ def __init__(self, pkg, libname, *routines): print("}") print() # Print JNI entry functions + print("static void *libhandle;") + print() print("jint JNI_OnLoad(JavaVM *vm, UNUSED void *reserved) {") print(" JNIEnv *env;") print(" if ((*vm)->GetEnv(vm, (void**)&env, JNI_VERSION_1_6) != JNI_OK) {") @@ -461,7 +461,7 @@ def __init__(self, pkg, libname, *routines): print(" return -1;") print(" }") print("") - print(" libhandle = dlopen(name, RTLD_LAZY);") + print(" libhandle = dlopen(name, RTLD_LAZY | RTLD_GLOBAL);") print(" if (!libhandle) {") print(" return -1;") print(" }") diff --git a/lapack/src/main/native/jni.c b/lapack/src/main/native/jni.c index 56f124a6..13378ef8 100644 --- a/lapack/src/main/native/jni.c +++ b/lapack/src/main/native/jni.c @@ -27507,11 +27507,9 @@ jboolean get_system_property(JNIEnv *env, jstring key, jstring def, jstring *res return TRUE; } -static void *libhandle; - jboolean load_symbols(void) { #define LOAD_SYMBOL(name) \ - name = dlsym(libhandle, #name); \ + name = dlsym(NULL, #name); \ if (!name) { \ return FALSE; \ } @@ -28244,6 +28242,8 @@ jboolean load_symbols(void) { return TRUE; } +static void *libhandle; + jint JNI_OnLoad(JavaVM *vm, UNUSED void *reserved) { JNIEnv *env; if ((*vm)->GetEnv(vm, (void**)&env, JNI_VERSION_1_6) != JNI_OK) { @@ -28318,7 +28318,7 @@ jint JNI_OnLoad(JavaVM *vm, UNUSED void *reserved) { return -1; } - libhandle = dlopen(name, RTLD_LAZY); + libhandle = dlopen(name, RTLD_LAZY | RTLD_GLOBAL); if (!libhandle) { return -1; }