I’m running into issues while trying to install the rJava package on my Mac. I have tried the solutions proposed online, including running R CMD javareconf, but without success (output is below). Any advice on how to fix this issue would be much appreciated.
Among the things I tried is the solution proposed here: rJava installation fails on macOS 10.14
open macOS_SDK_headers_for_macOS_10.14.pkg```
This had worked for me with my previous Mac, but not this time.
Output of:
```sudo R CMD javareconf```
Java interpreter : /usr/bin/java
Java version : 12.0.2
Java home path : /Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
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
/usr/local/Cellar/gcc/9.1.0/bin/gcc-9 -I"/usr/local/Cellar/r/3.6.1/lib/R/include" -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/include/darwin -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include -fPIC -g -O2 -c conftest.c -o conftest.o
/usr/local/Cellar/gcc/9.1.0/bin/gcc-9 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/Cellar/r/3.6.1/lib/R/lib -L/usr/local/Cellar/gcc/9.1.0/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/lib/server -ljvm -L/usr/local/Cellar/r/3.6.1/lib/R/lib -lR -lintl -Wl,-framework -Wl,CoreFoundation
ld: library not found for -lintl
collect2: error: ld returned 1 exit status
make: *** [conftest.so] Error 1
Unable to compile a JNI program
JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /usr/local/Cellar/r/3.6.1/lib/R
Done.
Related
This is likely an error installing PCRE2 (which I did using "sudo port install pcre2"), but when I "make" sample code for RInside, I get:
$ make rinside_sample0
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include -I/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RInside/include -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include rinside_sample0.cpp -L/usr/local/lib -F/Library/Frameworks/R.framework/.. -framework R -L/usr/local/lib -lpcre2-8 -llzma -lbz2 -lz -licucore -ldl -lm -liconv -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/Library/Frameworks/R.framework/Resources/lib -lRlapack /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RInside/lib/libRInside.a -o rinside_sample0
In file included from rinside_sample0.cpp:10:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RInside/include/RInside.h:26:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RInside/include/RInsideCommon.h:38:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp.h:57:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp/DataFrame.h:136:18: warning: unused variable 'data'
[-Wunused-variable]
SEXP data = Parent::get__();
^
1 warning generated.
ld: library not found for -lpcre2-8
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [rinside_sample0] Error 1
$
Thank you for the comment, Dirk. You got me pointed in the correct direction. I had two old versions of code: pcre2 and Rcpp.
I followed the directions for installing the latest version of "pcre2" here: https://izziswift.com/how-to-install-pcre-development-headers-on-mac-osx/.
I downloaded "pcre" version 10.39, cd'd to that directory, ran:
./configure
make
make install
After that, the examples in RInside compiled, but I got a runtime error:
$ ./rinside_sample0
Error: function 'Rcpp_precious_remove' not provided by package 'Rcpp'
Execution halted
$
Some searching showed that error arose from running an older version (1.0.6) of "Rcpp". I went into RStudio, typed "install.packages("Rcpp")" to update to version 1.0.7 and now everything runs!
Hopefully going through these steps will help anyone else who encounters these problems.
I'm trying to install the python library rpy2 in OS X (El Capitan) with R 3.4.
I did follow many posts on web and I end up replacing clang from xcode to one manually installed (after following http://thecoatlessprofessor.com/programming/openmp-in-r-on-os-x/#clang-before-3-4-0):
clang version 4.0.0 (tags/RELEASE_400/final)
Target: x86_64-apple-darwin15.5.0
Thread model: posix
InstalledDir: /usr/bin
Still, when I tried to install rpy2 (sudo pip3 install rpy2):
clang -bundle -undefined dynamic_lookup build/temp.macosx-10.11-x86_64-3.6/./rpy/rinterface/_rinterface.o -L/usr/local/lib -L/usr/local/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/sqlite/lib -Lbuild/temp.macosx-10.11-x86_64-3.6 -L/usr/local/lib -lpcre -llzma -lbz2 -lz -licucore -lm -liconv -lr_utils -o build/lib.macosx-10.11-x86_64-3.6/rpy2/rinterface/_rinterface.cpython-36m-darwin.so -fopenmp -F/Library/Frameworks/R.framework/.. -framework R
ld: library not found for -lomp
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
What's lomp? I'm not sure what I can do now.
UPDATE:
I try to reinstall llvm through brew:
brew reinstall --with-clang --with-lld --with-python --HEAD llvm
now installing rpy2 I got:
clang -bundle -undefined dynamic_lookup build/temp.macosx-10.11-x86_64-3.6/./rpy/rinterface/_rinterface.o -L/usr/local/lib -L/usr/local/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/sqlite/lib -Lbuild/temp.macosx-10.11-x86_64-3.6 -L/usr/local/lib -lpcre -llzma -lbz2 -lz -licucore -lm -liconv -lr_utils -o build/lib.macosx-10.11-x86_64-3.6/rpy2/rinterface/_rinterface.cpython-36m-darwin.so -fopenmp -F/Library/Frameworks/R.framework/.. -framework R
ld: library not found for -lomp
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
Although from the llvm installation I got the advice:
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/llvm/lib
CPPFLAGS: -I/usr/local/opt/llvm/include
do you know how to set it? It may be the reason it fails
This was discussed on the rpy2 issue tracker: https://bitbucket.org/rpy2/rpy2/issues/403/cannot-pip-install-rpy2-with-latest-r-340
Note that the issue was resolved and a precompiled binary wheel for rpy2-2.9.3 is now available on pypi.
when I am running install.packages("rJava")
Error:-
checking whether siglongjmp is declared... yes
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 : ''
java libs : ''
configure: error: One or more Java configuration variables are not set.
Make sure R is configured with full Java support (including JDK). Run
R CMD javareconf
as root to add Java support to R.
If you don't have root privileges, run
R CMD javareconf -e
to set all Java-related variables and then install rJava.
ERROR: configuration failed for package ‘rJava’
* removing ‘/usr/lib64/R/library/rJava’
The downloaded source packages are in
‘/tmp/Rtmpyht6l8/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("rJava", "/usr/lib64/R/library", repos = "http://ftp.iitm.ac .in/cran/") :
installation of package ‘rJava’ had non-zero exit status
I ran R CMD javareconf -e
Java interpreter : /usr/bin/java
Java version : 1.8.0_91
Java home path : /usr/java/jdk1.8.0_91/jre
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
trying to compile and link a JNI program
detected JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/java/jdk1.8.0_91/jre/../include -I/usr/java/jdk1.8.0_91/jre/../include/linux -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fpic -fPIC -c conftest.c -o conftest.o
gcc -m64 -std=gnu99 -shared -L/usr/lib64/R/lib -ldl -lpthread -lc -lrt -lcurl -lidn -lssh2 -lssl -lcrypto -lssl -lcrypto -ldl -lz -lgssapi -lldap -lz -lrt -o conftest.so conftest.o -L/usr/java/jdk1.8.0_91/jre/lib/amd64/server -ljvm -L/usr/lib64/R/lib -lR
/usr/bin/ld: cannot find -lcurl
collect2: ld returned 1 exit status
make: *** [conftest.so] Error 1
Unable to compile a JNI program
The following Java variables have been exported:
JAVA_HOME JAVA JAVAC JAVAH JAR JAVA_LIBS JAVA_CPPFLAGS JAVA_LD_LIBRARY_PATH
Also export JAVA_HOME= jdk_path
Can anyone please help me in this?
Install latest java version in your work station and set java home page inside Rstudio, i think it may work
Sys.setenv(JAVA_HOME="C:\\Program Files\\Java\\jre7")
I am trying to get a working R environnement on my mac.
I just updated to Mac OS 10.11.1.
From rStudio, install.packages("rJava") leads to this error:
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_66.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/jre/../include/darwin'
java libs : '-L/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/jre/lib/server -ljvm'
checking whether Java run-time works... yes
checking whether -Xrs is supported... yes
checking whether JNI programs can be compiled... yes
checking JNI data types...
configure: error: One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this.
ERROR: configuration failed for package ‘rJava’
* removing ‘/usr/local/lib/R/3.2/site-library/rJava’
The output of R CMD javareconf is:
Java interpreter : /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/jre/bin/java
Java version : 1.8.0_66
Java home path : /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home
Java compiler : /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/bin/javac
Java headers gen.: /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/bin/javah
Java archive tool: /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/bin/jar
System Java on OS X
trying to compile and link a JNI program
detected JNI cpp flags : -I/System/Library/Frameworks/JavaVM.framework/Headers
detected JNI linker flags : -framework JavaVM
clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include -I/usr/local/include -fPIC -g -O2 -c conftest.c -o conftest.o
conftest.c:4:5: warning: 'JNI_CreateJavaVM' is deprecated [-Wdeprecated-declarations]
JNI_CreateJavaVM(0, 0, 0);
^
/System/Library/Frameworks/JavaVM.framework/Headers/jni.h:1937:1: note: 'JNI_CreateJavaVM' has been explicitly marked deprecated here
JNI_CreateJavaVM(JavaVM **pvm, void **penv, void *args);
^
1 warning generated.
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress - L/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/lib - L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -L/usr/local/lib -o conftest.so conftest.o -framework JavaVM -F/usr/local/Cellar/r/3.2.2_1/R.framework/.. -framework R -lintl -Wl,-framework -Wl,CoreFoundation
JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home
Java library path:
JNI cpp flags : -I/System/Library/Frameworks/JavaVM.framework/Headers
JNI linker flags : -framework JavaVM
Updating Java configuration in /usr/local/Cellar/r/3.2.2_1/R.framework/Resources
I have no clue. Any idea to fix this?
Thanks
I had exactly the same problem, and finally resolved, via a solution I found here.
The new Mac OS X (10.11, El Capitan) has trouble with env variables.
The newest dev flavor of rJava manages to handle things correctly. Here is what I did to resolve it:
Download version 0.9-8 (rJava_0.9-8.tar.gz) from here
Install it from the downloaded source:
$ R CMD INSTALL ~/Downloads/rJava_0.9-8.tar.gz
(Or wherever you put it)
That's all it took!
I recently "upgraded" to XCode 5.2 and now a number of R packages will not work. I have a 15" MBP running OSX Mavericks 10.9.1 and am running R 3.0.2.
First, the mcmc function in the package diversitree broke and gave the following error:
Error in .External(list(name = "CppMethod__invoke_notvoid", address = <pointer: 0x0>, :
NULL value passed as symbol address
Furthermore, I cannot compile the package "geomorph" from source, and I get the following error:
clang: error: no such file or directory: 'SHLIB_LIBADD'
clang: error: no such file or directory: '='
make: *** [geomorph.so] Error 1
ERROR: compilation failed for package ‘geomorph’
So I believe the error is somewhere in the compilers. I tested this idea with:
> require(Rcpp)
> evalCpp("1+1")
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I"/Users/Chris/Library/R/3.0/library/Rcpp/include" -fPIC "-mtune=native -g -O2 -Wall -pedantic -Wconversion" -c file177c642d0b53.cpp -o file177c642d0b53.o clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -L/usr/local/lib -o sourceCpp_1783.so file177c642d0b53.o /Users/Chris/Library/R/3.0/library/Rcpp/lib/libRcpp.a SHLIB_LIBADD = -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput, :
Error 1 occurred building shared library.
WARNING: The tools required to build C++ code for R were not found.
Please install Command Line Tools for XCode (or equivalent).
clang: error: no such file or directory: 'SHLIB_LIBADD'
clang: error: no such file or directory: '='
make: *** [sourceCpp_1783.so] Error 1
Also this:
has_devel()
'/Library/Frameworks/R.framework/Resources/bin/R' --vanilla \
CMD SHLIB foo.c
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC "-mtune=native -g -O2 -Wall -pedantic -Wconversion" -c foo.c -o foo.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -L/usr/local/lib -o foo.so foo.o SHLIB_LIBADD = -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
clang: error: no such file or directory: 'SHLIB_LIBADD'
Error: Command failed (1)
clang: error: no such file or directory: '='
make: *** [foo.so] Error 1
I tried reinstalling Rcpp from source and that fails too:
clang: error: no such file or directory: 'SHLIB_LIBADD'
clang: error: no such file or directory: '='
make: *** [Rcpp.so] Error 1
I've spent hours now trying to troubleshoot this and I've run across numerous mentions of editing the Makeconf file to add clang. I have done this but still cannot get things that use C in R to work. I would greatly appreciate any help.
Are you using a CRAN-provided binary of R, or your own compiled version of R? Did you compile R with your new XCode compilers or the old ones?
My experience is that CRAN-R will work fine with a specific compiler toolchain, as long as you use the same toolchain for all the packages you compile. If you, for example, try to link a new-XCode compiled package to an old-XCode compiled Rcpp, you will have problems.
Your SHLIB_LIBADD error, as far as I can guess, says you did something weird in your Makevars or Makeconf and now things are going wrong in parsing the files. I'd be curious to see if you can reproduce this with a fresh, CRAN-provided R.
Can you reproduce the problem if you try to re-install R + all your packages? You should try re-installing R with a fresh library directory, and then re-installing these problematic packages, and going from there.