Skip to content
Prev 1868 / 2152 Next

Rmpi loads 2 versions of the same library

hi,

2014-03-14 4:16 GMT+09:00 Ross Boylan <ross at biostat.ucsf.edu>:
I also had the sense of incompatibility of this problem.
Did anyone try in other platforms?(exclude mac and linux)
The following corrections might be preferable for the time being.

--- Rmpi.orig/src/Rmpi.c    2013-03-27 02:21:49.000000000 +0900
+++ Rmpi/src/Rmpi.c    2014-03-14 11:36:43.000000000 +0900
@@ -18,6 +18,7 @@
 #include "Rmpi.h"

 #ifdef OPENMPI
+#define __USE_GNU
 #include <dlfcn.h>
 #endif

@@ -69,13 +70,19 @@

 #ifndef MAC
 #ifdef OPENMPI
-    if (!dlopen("libmpi.so.0", RTLD_GLOBAL | RTLD_LAZY)
-    && !dlopen("libmpi.so", RTLD_GLOBAL | RTLD_LAZY)){
-    //&& !dlopen("libmpi.dylib", RTLD_GLOBAL | RTLD_LAZY)
-     //&& !dlopen("libmpi.1.dylib", RTLD_GLOBAL | RTLD_LAZY)) {
-       Rprintf("%s\n",dlerror());
-        return AsInt(0);
-    }
+      { /* ifndef from MAC to __linux__ ? if only problem on linux */
+        Dl_info info_MPI_Init;
+        int rc = dladdr((void *)MPI_Init, &info_MPI_Init);
+        if(rc){
+          if (!dlopen(info_MPI_Init.dli_fname, RTLD_GLOBAL | RTLD_LAZY)){
+        Rprintf("%s\n",dlerror());
+        return AsInt(0);
+          }
+        }else{
+          Rprintf("%s\n",dlerror());
+          return AsInt(0);
+        }
+    }
 #endif
 #endif