I have a custom compiled R installation. I had to custom compile it in order to use MKL.
In my build.sbt
I have the following line
javaOptions += "-Djava.library.path=/Users/me/R-3.3.2/lib:/Users/taylor/Library/R/3.3/library/rJava/jri
and also:
fork := true
so javaOptions
works right.
To test this I fire up sbt
and attempt to load jri
with System.loadLibrary("jri")
. I get the following error:
java.lang.UnsatisifiedLinkError: /Users/me/R/3.3/library/rJava/jri/libjri.jnilib: dlopen(/Users/me/Library/R/3.3/library/rJava/jri/libjri.jnilib, 1): Library not loaded libR.dylib
So I went to see with otool
what it expects -
otool -L libjri.jnilib
in /Users/me/Library/R/3.3/library/rJava/jri
has the following in it: (remainder omitted)
libjri.jnilib
libjri.jnilib (compatibility version 0.0.0, current version 0.0.0)
...
libR.dylib (compatibility version 3.3.0, current version 3.3.2)
...
I thought this looked funny, so I copied libR.dylib
from /Users/me/R-3.3.2/lib
into /Users/me/Library/R/3.3/library/rJava/jri
to see if it was just looking around locally.
Unfortunately I still get the same error.
I'm at a complete loss on what I need to do to make this work, and it has ground my entire project to a halt. Has anyone experienced this and fixed it?
First, note that you shouldn't need to re-compile R in order to use MKL, because the CRAN OS X binaries are intentionally shipped such that you can point libRblas.dylib
to any compatible BLAS implementation - consider reading the R documentation.
As for the error, it seems that you have compiled R without framework support and/or have not installed it, hence libR
doesn't contain the full path. Also you have likely not used the recommended way to start your Java application use R CMD
. You can either use
install_name_tool -id <libR> <libR>
to fix your libR
manually (where <libR>
is the full path to your libR.dylib
), or you can use
install_name_tool -change libR.dylib <libR> \
/Users/me/Library/R/3.3/library/rJava/jri/libjri.jnilib
to force libjri
to pick up you location of libR
. There are other ways as well, such as setting DYLD_...
env vars before you start Java or using R CMD
.