gfortran not found when installing r-packages - r

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

Related

not able to install 'fable' package (ERROR: compilation failed for package ‘fable’)

I am trying to install fable running the command install.packages("fable"), as it says in https://cran.r-project.org/web/packages/fable/readme/README.html
however i am getting the following:
It says clearly that it is because i don't have llapack, lblas and lgfortran in my computer. But i am not sure how to procede here. I'm using Ubuntu 20.04.3 LTS
I'll appreciate any guidence.
To install from sources, you will need a GNU Fortran compiler installed. On Ubuntu this can be done with sudo apt install gfortran.
Alternatively, you can install a precompiled binary from the RStudio Package Manager - some guidance on how this can be done can be found here: https://packagemanager.rstudio.com/client/#/repos/1/overview

Can't get R to recognize installed libgfortran when installing packages

I'm trying to install packages in R that depend on libgfortran, but I keep getting this error:
dyld: Library not loaded: /usr/local/opt/gcc/lib/gcc/7/libgfortran.4.dylib
Referenced from: /usr/local/Cellar/r/3.4.3_1/lib/libR.dylib
Reason: image not found
I have gfortran installed through homebrew gcc:
❯❯ readlink `which gfortran`
../Cellar/gcc/8.2.0/bin/gfortran
There's a libgfortran available at /usr/local/opt/gcc/lib/gcc/8/libgfortran.5.dylib, but this is not the one R is looking for. How do I convince R to look for gcc 8 instead of gcc 7?
"How do I convince R to look for gcc 8 instead of gcc 7?"
You should not do that! Those libraries are NOT compatible, that's why soname is changed. The ABI is different. You need the correct version of GCC which was used to compile your R package. See very similar (but Linux) questions and answers like R v3.4.0-2 unable to find libgfortran.so.3 on Arch How to install libgfortran.so.4 on ubuntu 16.06
You really need the compatible library or update your R to a version that uses GCC 8.

Cannot install Ckmeans package on Ubuntu 18.04

I am not able to install Rcpp and many other packages (e.g. devtools) as a requirement for the opm-package.
Ubuntu 18.04, R Version: 3.5.1, gcc version 7.3.0
Can anybody give suggestions to fix this issue?
EDIT: I managed now to install rcpp via apt-get; I used the below suggested repos and R 3.5.1. Now I am stuck with installing Ckmeans (Package maintainer contacted).
EDIT_2: The author sent me a new version of Ckmeans, but the problem persists. To sum up: unable to install ckmeans; Ubuntu 18.04, R 3.5.1, repos c2d4u3.5, cran repos.
update: I removed the R-bionic ppa and reinstalled R (3.5.0) with r-base-dev. I managed to tackle down nearly all the dependencies for opm, if not within R, so at least with the ubuntu-r-cran-packages (from the abovely mentioned repos); only one dependency is missing (OPM-Script): Ckmeans. I tried to install from source with 5 different versions, but so far without success.
After today's System-update I was able to install Ckmeans.1d.dp_4.2.2 and opm_1.3.72 without any problem.

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

Problems compiling rJava with RStudio on macOS Sierra 10.12.6

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.

Resources