Problems compiling rJava with RStudio on macOS Sierra 10.12.6 - r

I am trying to install the rJava package into Rstudio using these instructions:
https://github.com/MTFA/CohortEx/wiki/Run-rJava-with-RStudio-under-OSX-10.10,-10.11-(El-Capitan)-or-10.12-(Sierra)
However, when I run this command:
unset JAVA_HOME R --quiet -e 'install.packages("rJava", type="source", repos="http://cran.us.r-project.org")'
I am getting this error:
clang: error: unsupported option '-fopenmp'
Any workarounds or suggestions?

Take a look here. Lots depends on R version. It might be that you need to recompile rJava
R 3.4, rJava, macOS and even more mess ;)
R, Java, rJava and macOS adventures
You need compiler with OpenMP support - thus, you need to use different clang version comparing to what you get out of the box.

Related

Unable to install R packages due to library not found

In any R package I try to install, I get the following error message:
ld: library not found for -lintl
collect2: error: ld returned 1 exit status
make: *** [utf8.so] Error 1
I'm not sure how to make this a reprex, but I am running:
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin19.5.0 (64-bit)
Running under: macOS Catalina 10.15.5
What does this error message (ld: library not found for -lintl) mean and how can I fix it to be able to install R packages (the packages I have tried are texreg and lme4)? Thank you.
Edit: I apologize, I thought I had included this with my post. I am not missing gettext (as per Link error installing Rcpp "library not found for -lintl"), and I followed the instructions to export the LPDFLAGS and CPPFLAGS so that they are linked.
As best I can tell, the problem is the ~/.R/Makevars file, which currently looks like this, where I've commented out things I've added to it based on googling.
CC=/usr/local/Cellar/gcc/9.3.0_1/bin/gcc-9
CXX=/usr/local/Cellar/gcc/9.3.0_1/bin/g++-9
CXX11=/usr/local/Cellar/gcc/9.3.0_1/bin/g++-9
CXX14=/usr/local/Cellar/gcc/9.3.0_1/bin/g++-9
cxx17=/usr/local/cellar/gcc/9.3.0_1/bin/g++-9
cxx1X=/usr/local/cellar/gcc/9.3.0_1/bin/g++-9
LDFLAGS=-L/usr/local/Cellar/gcc/9.3.0_1/lib
#FLIBS=-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0
#CC=/usr/local/clang4/bin/clang
#CXX=/usr/local/clang4/bin/clang++
#CXX1X=/usr/local/clang4/bin/clang++
#CXX98=/usr/local/clang4/bin/clang++
#CXX11=/usr/local/clang4/bin/clang++
#CXX14=/usr/local/clang4/bin/clang++
#CXX17=/usr/local/clang4/bin/clang++
#LDFLAGS=-L/usr/local/clang4/lib
Apparently, I needed to remove all the lines from ~/.R/Makevars and I was able to install lme4. I did get some warnings, but library(lme4) works.
If you're using a mac with an Apple Silicon chip (like the M1), then you can try adding this to ~/.R/Makevars:
CFLAGS=-I/opt/homebrew/include
CPPFLAGS=-I/opt/homebrew/include
CXXFLAGS=-I/opt/homebrew/include
CXX11FLAGS=-I/opt/homebrew/include
LDFLAGS=-L/opt/homebrew/lib
This allows R to find the needed libraries. You will need to first ensure you have the needed compilers and dependencies installed. You can usually do this with brew.

R package data.table fails to install/compile on system with R 3.5.1

I'm trying to reinstall data.table with:
install.packages("data.table")
And I'm getting the following compile error:
forder.c: In function ‘range_str’:
forder.c:296: error: expected end of line before ‘update’
make: *** [forder.o] Error 1
ERROR: compilation failed for package ‘data.table’
The package I'm getting from cran is: data.table_1.12.0.tar.gz
Which should be a version that works with 3.5, unlike the issues with data.table 1.10
The system this is on is RHEL 6.9 + I also already updated gcc via yum.
R versions are also up2date from yum: R-core-3.5.1-1.el6.x86_64 R-core-devel-3.5.1-1.el6.x86_64
Everything I could find on google for this was either related to Rtools (Windows) or the older version 1.10, this seems like something else.
You can install an older version of data.table on EL6. 1.11.4 works; I'm not sure which, if any, newer versions do.
require(devtools)
install_version("data.table", version = "1.11.4")
More on installing older versions of packages: https://support.rstudio.com/hc/en-us/articles/219949047-Installing-older-versions-of-packages
The in the error message mentioned line is:
#pragma omp atomic update
which is functionality that is apparently not available in GCC before version 4.7 and on RedHat 6.9 the highest I get from standard repos is 4.4.7 at the moment.
Means I need a newer compiler, which can handle this openmp functionality.
I had the same error when installing data.table with R 3.5.0
On a CentOS 6.10 (which has gcc and g++ version 4.4.7), here is how I was able to install data.table:
yum install devtoolset-6
scl enable devtoolset-6 bash
now if you do: `which gcc` -v , you should see a higher gcc version
R
to start R 3.5.0
install.packages("data.table")
now I was able to install data.table

Error: package or namespace load failed for 'RevoUtilsMath'

I'm getting a little bit crazy with this issue. I'm trying to install an R package using conda in my environment (python 2.7) in my home on a cluster (i.e. without root permissions). I firstly installed R in my env using:
conda install -c r r=3.4
Then:
conda install -c conda-forge python-igraph
(because igraph is required by my library of interest)
and finally:
conda install -c conda-forge r-diffusionmap
Unfortunately when I launch R the following message appears:
Error: package or namespace load failed for 'RevoUtilsMath': .onLoad
failed in loadNamespace() for 'RevoUtilsMath', details: call: NULL
error: Remove Microsoft R and then re-install. Be sure to select MKL
libraries as an install option.
During startup - Warning message:
package 'RevoUtils' was built under R version 3.4.3
What does it mean? How can I solve this?
Thank you in advance
I had this same issue after I installed some libraries (Rcpp included) in my root R, but not my conda environment (which screwed up conda). This would cause kernel death anytime a jupyter notebook running R was even opened.
The fix for me was:
Uninstall Anaconda3
Reinstall Anaconda3
Reinstall all the libraries I needed (mostly just Bioconductor in R)
A few other issues popped up, like package inconsistencies, but I dealt with those as described here.
All R packages on conda-forge (or Bioconda) are compiled against one single version or R for each new release branch (usually starting from patch 1, so 3.x.1, except for 3.4.3). This is due to ABI incompatibility problems.
Also note that defaults and conda-forge channels are (where) not binary compatible (although now they should be). And that since 2018 the default anaconda channel is distributing Microsoft R Open as default R, whether all packages from conda-forge should be preferably used with R from conda-forge.
You should be able to solve this issue by installing R using conda install -c conda-forge r-base.
the same error information for me when I open R for run code in ubuntu platform(18.4), and there is no other useful methods to solve it.My R version is 3.4.3.enter image description here

R can't install devtools or git2r due to lack of zlib on macOS 10.12.3 and 10.12.5

I am trying to install two packages in R (3.3.2): devtools and git2r. They are depending on the existence of zlib. This comes with macOS Sierra (10.12.3) and it's version 1.2.8 by default.
When I'm trying to install these packages I get the error below.
I've been trying a lot of things.
directly installing via CRAN in RStudio: no effect.
trying to locate zlib on macOS: can't find zlib.
installing via R CMD INSTALL git2r: no effect.
I notice someone has a similar issue posted on GitHub: https://github.com/ropensci/git2r/issues. There is no solution yet.
Does anyone here have an idea?
Thanks!
Sander
ERROR MESSAGE BELOW
configure error in "/private/tmp/RtmpP6HZFx/R.INSTALLe73412909267/git2r"
configure error
The zlib library that is required to build git2r was not found.
Please install:
zlib1g-dev (package on e.g. Debian and Ubuntu)
zlib-devel (package on e.g. Fedora, CentOS and RHEL)
and try again.
If the zlib library is installed on your system but the git2r configuration is unable to find it, you can specify the include and lib path to zlib with:
"R CMD INSTALL --configure-args='--with-zlib-include=INCLUDE_PATH --with-zlib-lib=LIB_PATH' git2r"
See "config.log" for more details
ERROR: configuration failed for package "git2r"
*removing "/usr/local/lib/R/3.3/site-library/git2r"
UPDATE: the same issue persists on macOS X 10.12.5 in combination with R 3.4.0 - the latter I need for DESeq2.
Solution...Mmm. Not really. I simply uninstalled R and all the packages, and than I reinstalled everything again. I installed R and RStudio via homebrew, following the instructions here: https://rud.is/b/2015/10/22/installing-r-on-os-x-100-homebrew-edition/.
Oddly enough: all issues disappeared.
UPDATE #1: this solution does not - obviously - work for the combination R 3.4.0 and macOS X 10.12.5. We need a solution for this issue.
UPDATE #2: I have discovered what I believe was the issue: a wrong path to the xcode command line tools.
sudo xcode-select --reset did the trick and now xcode-select -p points to /Library/Developer/CommandLineTools. And which xcode-select points to /usr/bin/xcode-select. Googling I discovered that it is not needed to install Xcode through the App Store as it states on http://railsapps.github.io/xcode-command-line-tools.html:
"On earlier versions of macOS, it was more difficult to install Xcode Command Line Tools. It required a huge download of the full Xcode package from the Mac App Store or registration as an Apple developer for a smaller Command Line Tools package. Mac OS X Mavericks made installation of Xcode Command Line Tools much simpler.".
i was having the same problem. i have a note 8(samsung). just go to GitHub and install zlib from there.

gfortran not found when installing r-packages

I am repeatedly encountering the following error
/usr/bin/ld: cannot find -lgfortran
when trying to install a lot of r-packages (e.g. igraph, ergm, blockmodels, and I guess every package that requires gcc and fortran in some way or another)
I run R on Ubuntu Trusty, and I have recently upgraded R from 3.1.0 to 3.3.1.
When on 3.1.0, I had been able to install igraph and ergm (and others) without any problem, but not blockmodels.
I have checked for the presence of libgfortran on my system: it is there. Actually there is more than one version of it (3, 4.7, 4.8) and also libgfortran-dev is installed (multiple versions as well)
Any idea of what is going on?
Thank you for any advice.
In Arch Linux, the gfortran package is named gcc-fortran. To install it:
sudo pacman -S gcc-fortran

Resources