I want to install rJava on macOS Sierra 10.12.4. My current Java version is Java version: 1.8.0_131
, according to R CMD javareconf|grep version
. I have installed Java with Homebrew's cask.
My Java runs the following
$ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
My R version is
R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin11.4.2 (64-bit)
R Java config runs such that
$ R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.8.0_131
Java home path : /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
Non-system Java on macOS
trying to compile and link a JNI program
detected JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
During startup - Warning messages:
1: Setting LC_COLLATE failed, using "C"
2: Setting LC_TIME failed, using "C"
3: Setting LC_MESSAGES failed, using "C"
4: Setting LC_MONETARY failed, using "C"
clang -I/Volumes/osx/201705_anaconda/anaconda/lib/R/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/../include/darwin -I/Volumes/osx/201705_anaconda/anaconda/include -fPIC -I/Volumes/osx/201705_anaconda/anaconda/include -c conftest.c -o conftest.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Volumes/osx/201705_anaconda/anaconda/lib/R/lib -arch x86_64 -L/Volumes/osx/201705_anaconda/anaconda/lib -lgfortran -L/Volumes/osx/201705_anaconda/anaconda -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/server -ljvm -L/Volumes/osx/201705_anaconda/anaconda/lib/R/lib -lR -lintl -liconv -lc -Wl,-framework -Wl,CoreFoundation
JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
Updating Java configuration in /Volumes/osx/201705_anaconda/anaconda/lib/R
Done.
which looks to be properly set-up as guided here and this SO thread unable to compile JNI program rJava so the JDK looks to be correctly installed.
I get the linker error with the command install.packages("rJava")
checking Java support in R... present:
interpreter : '/usr/bin/java'
archiver : '/usr/bin/jar'
compiler : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags : '-I/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/../include/darwin'
java libs : '-L/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/server -ljvm'
...
ld: library not found for -licuuc
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libjri.jnilib] Error 1
make[1]: *** [src/JRI.jar] Error 2
make: *** [jri] Error 2
ERROR: compilation failed for package ‘rJava’
I have got the same error despite Java sources: official JDK and Homebrew's Java return the same linker/library error.
What could be causing this linker/library licuuc error with Anaconda and how to fix it?
Old threads
Install rJava on macOS Sierra 10.12.1: linker error licuuc: a solution candidate with MacPorts
rJava load error in RStudio/R after "upgrading" to OSX Yosemite
Fixes that I have tried
options("java.home")
returns NULL sooptions("java.home"="/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/")
as guided by hereUnistalled Homebrew's Java and replaced it with Oracele's Java and JDK here: the same licuuc library/linker error persists. I tried
sudo Rscript -e 'install.packages("rJava", repos="http://rforge.net", type="source")'
guided by this but the samelicuuc library not found
error.Updated macOS from El Capitan 10.11.6 to Sierra 10.12.4 but the same licuuc library/linker error persists.
Running without sudo, javac missing (following this here and this here). This error may be easiest to fix with pointing the javac directory there to
/usr/bin/javac
but better solution? When I run it with sudo, I got the same licuuc error.R CMD javareconf -e LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_LD_LIBRARY_PATH Rscript -e 'install.packages("rJava", repos="http://rforge.net", type="source")' Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/bin/javac" (-1) make[2]: *** [org/rosuda/JRI/Rengine.class] Error 2 make[1]: *** [src/JRI.jar] Error 2 make: *** [jri] Error 2 ERROR: compilation failed for package ‘rJava’
After removal of Anaconda
conda install anaconda-clean; anaconda-clean --yes; rm -rf ~/anaconda
, guided here, and installing R with cask such thatbrew cask install r-app; sudo R CMD javareconf; Rscript -e 'install.packages("rJava", repos="http://rforge.net", type="source")'
so getting a new errorclang: error: unsupported option '-fopenmp' make[2]: *** [libjri.jnilib] Error 1 make[1]: *** [src/JRI.jar] Error 2 make: *** [jri] Error 2 ERROR: compilation failed for package ‘rJava’
201705_anaconda/anaconda
you are using anaconda to manage your R install instead ofbrew cask
? Switch that. – Genicconda install anaconda-clean; anaconda-clean --yes; rm -rf ~/anaconda
andbrew install r
. Restarted the terminal but$ R CMD javareconf /usr/local/Cellar/r/3.4.1/lib/R/bin/Rcmd: line 62: exec: javareconf: not found
, ideas? Did your paths get automatically set up with brew R installation? – Gladbrew cask r-app
. Usingbrew install r
is going to give you something less than what you desire. Secondly, where isjava
from? – GenicR CMD javareconf
with the new R-app version of R? – Genicxcode-select --install
), but I don't think that's the case... – Genicxcode-select --install
and installed thebrew cask install r-app
sosudo R CMD javareconf
started working again. A new errorclang: error: unsupported option '-fopenmp'
and no licuuc error anymore so related to this here potentially. – Gladbrew install homebrew/versions/gcc49 --without-multilib
from the blog, still onmake bootstrap
, now about 1 hour lasted to run it :/ – GladrJava
installed even with Anaconda. – Glad