cannot install rJava on macOS Catalina 10.15.1 - macos-catalina

My mac system is macOS Catalina 10.15.1, and my R version is 3.6.1. When I try to install the rJava package on Rstudio using install.packages("rJava", type="source), it comes with error:
make: *** [jri_glue.o] Error 1
ERROR: compilation failed for package ‘rJava’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava’
Warning in install.packages :
installation of package ‘rJava’ had non-zero exit status
I have tried sudo R CMD javareconf and then reinstall the rJava package but it does not work. When I use sudo R CMD javareconf on terminal, it shows that
ava interpreter : /usr/bin/java
Java version : 13.0.2
Java home path : /Library/Java/JavaVirtualMachines/jdk-13.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
gcc-7 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home/include/darwin -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -mtune=native -g -O2 -Wall -pedantic -Wconversion -c conftest.c -o conftest.o
gcc-7 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home/lib/server -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home
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 /Library/Frameworks/R.framework/Resources
Done.
This problem happened before and I use this solution trouble installing and loading rJava on mac El Capitan. But when my mac is updated to Catalina 10.15.1, the solution does not work. I am not familiar with java. How to install rJava successfully in such situation?

Related

Rcpp does not compile on Mac OS Monterey, R 4.1.2., clang error

Trying to get Rcpp to work on R 4.1.2 on Mac OS Monterey using an Intel computer.
> library(Rcpp)
> evalCpp("2 + 2")
clang++ -mmacosx-version-min=10.13 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include" -I"/private/var/folders/jz/977gqfr957g_rlgw1h05152w0000gq/T/Rtmp8hmDZ5/sourceCpp-x86_64-apple-darwin17.0-1.0.8" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -c file152f71a55f97c.cpp -o file152f71a55f97c.o
clang++ -mmacosx-version-min=10.13 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o sourceCpp_2.so file152f71a55f97c.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir, :
Error 1 occurred building shared library.
clang: error: no such file or directory: '/Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib'
make: *** [sourceCpp_2.so] Error 1
I have followed Coatless Professor's instructions:
https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/
I believe Xcode Command Line Tools and gfortran are installed:
$which gcc
/usr/bin/gcc
$which gfortran
/usr/local/bin/gfortran
and I have removed both ~/.R/Makevars and ~/.Renviron.
Any help would be much appreciated -- thanks so much!
There is an old reference to a prior version of the clang compiler present.
In R, please type:
unlink("~/.R/Makevars")
unlink("~/.Renviron")
Please restart R and, then, try:
Rcpp::evalCpp("1+1")

R installation of package `later` fails

Software info:
Linux Kernel: 4.14.83-1-MANJARO
R: 3.5.1
Rcpp: 1.0.0
g++ g++ (GCC) 8.2.1 20180831
I'm trying to install the later package from CRAN, but it fails due to a compilation error and I can't figure out whether there is something wrong with my own configuration or the package. The installation stops after the call
g++ -I"/usr/include/R/" -DNDEBUG -pthread -DTHREADS_H_SUPPORT=1 -I"/home/karpfen/R-libs/Rcpp/include" -I"/usr/lib/R/library/BH/include" -D_FORTIFY_SOURCE=2 -fopenmp -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -c timestamp_win32.cpp -o timestamp_win32.o
with the error message
make: *** No rule to make target '-fopenmp', needed by 'later.so'. Stop.
Rcpp and other packages depending on it work as expected. Is there anything that I could be doing wrong here? I tried reinstalling R + packages already, but no changes here.
Edit:
The first few lines of the installation output are
* installing *source* package ‘later’ ...
** package ‘later’ successfully unpacked and MD5 sums checked
Running configure script
Using CC=gcc
Using CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt
Using CPPFLAGS=-D_FORTIFY_SOURCE=2
C11-style threads.h support detected.
Edit2:
System information (from /etc/lsb-release)
DISTRIB_ID=ManjaroLinux
DISTRIB_RELEASE=18.0.0
DISTRIB_CODENAME=Illyria
DISTRIB_DESCRIPTION="Manjaro Linux"

Compile error with RcppArmadillo and R 3.1.3 and Mac Yosemite

I have recently installed R 3.1.3. I am using a Mac with Yosemite system and my Xcode is of version 6.2.
After I source the CPP file using sourceCpp("try.cpp"), I get the following error. My try.cpp file has
#include <RcppArmadillo.h>
#include <math.h>
The error is below in R
ld: warning: directory not found for option '-L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2'
ld: library not found for -lquadmath
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sourceCpp_15736.so] Error 1
clang++ -arch x86_64 -ftemplate-depth-256 -I/Library/Frameworks/R.framework/Resources/include -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -mtune=core2 -O3 -c CAR.cpp -o CAR.o
clang++ -arch x86_64 -ftemplate-depth-256 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module - multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib - L/usr/local/lib -o sourceCpp_15736.so CAR.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
Error in sourceCpp("~/RA2015/Code/BYMCAR/CAR.cpp") :
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).
I have installed the command line tools for Xcode, my gfortran version is 4.9.0
But when I type
gfortran --version
It has the following error:
gfortran: warning: couldn’t understand kern.osversion ‘14.1.0
When I use R 3.1.2, I did not encounter this problem before!
Any help is appreciated!
After some finding I find a solution online.
If you have same problem with me, just type
curl -O http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2
sudo tar fvxz gfortran-4.8.2-darwin13.tar.bz2 -C /
on the terminal and sourceCpp can run smoothly.
A detailed explanation can be found at [http://www.thecoatlessprofessor.com/programming/rcpp-rcpparmadillo-and-os-x-mavericks-lgfortran-and-lquadmath-error]

capybara-webkit on yosemite g++: error: unrecognized command line option '-Xarch_x86_64'

I'm having problem installing on OS X 10.10 Yosemite, running with gcc4.9.2 and qt 4.8.6 installed via Brew.
gem install capybara-webkit
Building native extensions. This could take a while...
ERROR: Error installing capybara-webkit:
ERROR: Failed to build gem native extension.
/usr/local/var/rbenv/versions/2.1.4/bin/ruby extconf.rb
cd src/ && /usr/local/bin/qmake /usr/local/rbenv/gem/gems/capybara-webkit-1.3.1/src/webkit_server.pro -spec /usr/local/Cellar/qt/4.8.6/mkspecs/macx-g++ -o Makefile.webkit_server
cd src/ && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f Makefile.webkit_server
g++ -pipe -O2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_NO_DEBUG -DQT_WEBKIT_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Cellar/qt/4.8.6/mkspecs/macx-g++ -I. -I/usr/local/Cellar/qt/4.8.6/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.6/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.6/lib/QtNetwork.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.6/lib/QtNetwork.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.6/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.6/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.6/lib/QtWebKit.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.6/lib/QtWebKit.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.6/include -Ibuild -F/usr/local/Cellar/qt/4.8.6/lib -x c++-header -c stable.h -o build/webkit_server.gch/c++
g++: error: unrecognized command line option '-Xarch_x86_64'
make[1]: *** [build/webkit_server.gch/c++] Error 1
make: *** [sub-src-webkit_server-pro-make_default-ordered] Error 2
Command 'make' failed
I had the same problem using GCC installed via MacPorts (tested several versions up to gcc5). The solution for me was using g++ supplied with the XCode command line tools. I uninstalled all MacPorts GCC versions. Below version details of the g++ command that worked.
$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
A similar problem was asked here: QT Creator adds -Xarch.

gem install unf_ext -v '0.0.6' fails on Mountain Lion mac

This is the error I get when I run bundle install
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/sam/.rvm/rubies/ree-1.8.7-2012.02/bin/ruby extconf.rb
checking for main() in -lstdc++... yes
checking for ruby/encoding.h... no
creating Makefile
CXX is automatically set to g++-4.6
make
g++-4.6 -I. -I/opt/local/include -I. -I/Users/sam/.rvm/rubies/ree-1.8.7-2012.02/lib/ruby/1.8/i686-darwin12.5.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -g -O2 -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl098/include -fno-common -pipe -fno-common -c unf.cc
make: g++-4.6: No such file or directory
make: *** [unf.o] Error 1
Gem files will remain installed in /Users/sam/.rvm/gems/ree-1.8.7-2012.02#global/gems/unf_ext-0.0.6 for inspection.
Results logged to /Users/sam/.rvm/gems/ree-1.8.7-2012.02#global/gems/unf_ext-0.0.6/ext/unf_ext/gem_make.out
An error occurred while installing unf_ext (0.0.6), and Bundler cannot continue.
Make sure that `gem install unf_ext -v '0.0.6'` succeeds before bundling.
It looks like g++ 4.6 is missing.
which g++ returns /usr/bin/g++ but which g++-4.6 returns nothing.
I definitely have Xcode Developer Tools installed. I'm not really sure what to do. How can I get bundle install to succeed?
Installed fine using jruby. Seems to be a problem with the ree version I was using.