I am having issues installing R packages in a conda environment on MacOS 10.15.4. The command install.packages() in R leads to the following type of errors (I am not pasting the full log):
ld: symbol(s) not found for architecture x86_64
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
Error 1
ERROR: compilation failed for package ‘xml2’
checking for gcc... x86_64-apple-darwin13.4.0-clang
checking whether the C compiler works... no
configure: error: in `/private/var/folders/k6/p2cdz1dx32g3p4hmwghns3fc0000gn/T/RtmpdPz2VA/R.INSTALL4817a82715f/uuid':
configure: error: C compiler cannot create executables
I am using r version 3.6.1 on a platform x86_64-apple-darwin13.4.0
The clang version is:
clang version 4.0.1 (tags/RELEASE_401/final)
Target: x86_64-apple-darwin19.4.0
Thread model: posix
InstalledDir: /opt/anaconda3/envs/r_omics/bin
So I assumed there was an issue/conflict with the way the C compilers on my computer process R-packages installation but I don't know how to solve this.
Somehow I manage to install some of the packages through conda install but I don't manage through this to recover the environment I need.
Thank you very much for your help
Related
I've been trying many different ways to install RcppArmadillo, but I don't get it to work
install.packages(c('Rcpp'))
Sys.setenv("PKG_CXXFLAGS"="-std=c++11")
install.packages(c('RcppArmadillo'),type = "source")
It gives me this error:
ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0'
ld: library not found for -lquadmath
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [RcppArmadillo.so] Error 1
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo’
Obviously, I don't have x86_64-apple-darwin18/8.2.0 since I installed gfortran for the apple silicon architecture.
Mac version:
macOS Big Sur
11.2.3
Apple M1
R version:
version
_
platform x86_64-apple-darwin17.0
arch x86_64
os darwin17.0
system x86_64, darwin17.0
status
major 4
minor 0.4
year 2021
month 02
day 15
svn rev 80002
language R
version.string R version 4.0.4 (2021-02-15)
nickname Lost Library Book
I think I found an issue. First, I follow this tutorial : R COMPILER TOOLS FOR RCPP ON MACOS
Once completed, it gaves me almost the same error as you mentioned in your post :
ld: warning: directory not found for option '-L/opt/R/arm64/gfortran/.....'
ld: library not found for -lgfortran clang: error: linker command failed
with exit code 1 (use -v to see invocation)
It seems, R is looking for gfortran in /opt/R/arm64 folder.
In the turorial it indicates that gfortran is installed in the /usr/local/gfortran folder.
I created a symbolic link in the /opt/R/arm64 which refers to /usr/local/gfortran with the command
ln -s /usr/local/gfortran /opt/R/arm64
One can set FLIBS in ~/.R/Makevars to one of the following options
# homebrew gfortran
FLIBS=-L/opt/homebrew/opt/gfortran/lib
# gfortran included in R
FLIBS=-L/opt/R/arm64/gfortran/lib
In addition one might want to also define F77 and FC as
F77 = /opt/R/arm64/gfortran/bin/gfortran
FC = /opt/R/arm64/gfortran/bin/gfortran
To verify, try installing the glmnet package which should now succeed.
OK, this is driving me crazy.
I'm attempting to use Conda as a quasi-package manager for R on my Mac (OS 10.15) as I have done (successfully) on other Unix installations.
Repeatedly, the error I get is the following
Before the creation of a new conda environment, we have:
$ gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
and
$ which clang
/usr/bin/clang
We create a new empty environment and check again
$ conda create --name r_env
$ conda activate r_env
$ gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ which clang
/usr/bin/clang
Great. So far so good.
Now we install R and check again.
$ conda install r=3.6
$ gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ which clang
/Users/dgarfield/miniconda3/envs/r_env/bin/clang
$ clang -v
clang version 4.0.1 (tags/RELEASE_401/final)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Users/dgarfield/miniconda3/envs/r_env/bin
It appears that we have a new clang!
Why is this a problem?
$ R
> install.packages("XML")
trying URL 'https://cran.uni-muenster.de/src/contrib/XML_3.98-1.20.tar.gz'
Content type 'application/x-gzip' length 1600829 bytes (1.5 MB)
==================================================
downloaded 1.5 MB
* installing *source* package ‘XML’ ...
** package ‘XML’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... x86_64-apple-darwin13.4.0-clang
checking whether the C compiler works... no
configure: error: in `/private/var/folders/dg/hbvl43fn0b7flfk6l__3bwth0000gq/T/Rtmplh4pEL/R.INSTALL12b2d7b634136/XML':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘XML’
* removing ‘/Users/dgarfield/miniconda3/envs/r_env/lib/R/library/XML’
The downloaded source packages are in
‘/private/var/folders/dg/hbvl43fn0b7flfk6l__3bwth0000gq/T/RtmpaiTLe8/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("XML") :
installation of package ‘XML’ had non-zero exit status
This works perfectly fine on a standard (non-Conda) installation. My guess is that the culprit is this new clang.
Following what I have seen elsewhere, I have tried this with
CONDA_BUILD_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
and
CONDA_BUILD_SYSROOT=/opt/MacOSX10.9.sdk
So it doesn't seem to be anything too weird with the headers (??). But I'm out of ideas and could use some guidance.
(and yes, I know that in the case of XML, conda could to the install for me, but that isn't the case for all packages).
Thanks!
I'm trying to install an R package called rcdd using conda build and there is a problem with the C compiler. Note that this problem looks very similar to
Conda build R package fails at C compiler issue on MacOS Mojave however as (i) that question remains unanswered, and (ii) this relates to different package, I think this is not a duplicate question.
I'm using MacOS Mojave, conda 4.6.8. In a new conda environment with r-base and r-essentials
installed, I try
conda install conda-build
conda skeleton cran --recursive rcdd
conda build r-rcdd
and get the following error
* installing *source* package ‘rcdd’ ...
** package ‘rcdd’ successfully unpacked and MD5 sums checked
checking for gcc... x86_64-apple-darwin13.4.0-clang
checking whether the C compiler works... no
configure: error: in `/Users/pjethwa/miniconda3/envs/r_env/conda-bld/r-rcdd_1553173041138/work':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘rcdd’
The config.log file contains the same error message. This same error also appears when I try to install directly from R - i.e. using install.packages('rcdd'). I am able, however, to install this package using a version of R which was not installed by conda. This solution is unsatisfactory as I would like to use rpy2 to interface python and R, which seems to require that R be installed by conda (e.g. see Getting Segmentation fault Core dumped error while importing robjects from rpy2)
My clang/gcc versions are:
(r_env) myusername:~ clang --version
clang version 4.0.1 (tags/RELEASE_401/final)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Users/myusername/miniconda3/envs/r_env/bin
(r_env) myusername:~ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
I have looked at the multiple sources to figure out how to install rgeos and rgdal on Mac OS X High Sierra in a way that works with Anaconda Navigator. I mention Anaconda because I want to be able to build static project-specific, package environments to ensure that my projects work 6 months from now when the dependent packages change. I have successfully installed and used both rgeos and rgdal on a couple other computers but seem to be having issues on a new computer. I want to launch Shiny apps from Anaconda Navigator's RStudio. None of the solutions I found, listed below, worked:
https://dyerlab.ces.vcu.edu/2015/03/31/install-rgeos-on-osx/
https://cran.rstudio.com/web/packages/rgeos/rgeos.pdf
http://tlocoh.r-forge.r-project.org/mac_rgeos_rgdal.html
https://anaconda.org/conda-forge/r-rgdal
Based on the above sources and my slow progression through a series of error messages, I tried the following:
Install GDAL 2.2 Complete [30.0 MiB] 2018-3-10 from http://www.kyngchaos.com/software/frameworks. This installs GDAL, GEOS, PROJ, SQLite and UnixImageIO frameworks.
The above installed without an error message. But attempting to install rgeos gave an error message:
configure: error: geos-config not found or not executable.
Consequently, either the install failed and didn't notify me, or there is some type of $PATH issue (?). On a blog, someone suggested to do the following in response to the aforementioned issue:
brew install geos
The above completed successfully. So I went into RStudio and tried the following, which resolved the former error but produced a new one:
install.packages("~/Downloads/rgeos_0.3-28.tar.gz", repos = NULL, type = "source")
installing source package ‘rgeos’ ...
configure: CC: x86_64-apple-darwin13.4.0-clang
configure: CXX: x86_64-apple-darwin13.4.0-clang++
configure: rgeos: 0.3-28
checking for /usr/bin/svnversion... yes
cat: inst/SVN_VERSION: No such file or directory
configure: svn revision:
checking for geos-config... /usr/local/bin/geos-config
checking geos-config usability... yes
configure: GEOS version: 3.6.2
checking geos version at least 3.2.0... yes
checking geos-config clibs... yes
checking geos_c.h presence and usability... no
configure: error: geos_c.h not found in standard or given locations.
ERROR: configuration failed for package ‘rgeos’
removing ‘/Users/aloha2018/anaconda2/lib/R/library/rgeos’
Warning in install.packages :
installation of package ‘/Users/aloha2018/Downloads/rgeos_0.3-28.tar.gz’ had non-zero exit status
Any ideas on what to try next?
Naturally, I already tried in an RStudio application launched from Anaconda Navigator:
install.packages("rgeos")
install.packages("rgdal")
both from CRAN and from tar.gz. But it seems like it is unable to find a file called geos_c.h, which does indeed exist on my computer at:
/Library/Frameworks/GEOS.framework/Versions/3B/Headers/geos_c.h
Is there a way to tell RStudio to look in the directory containing that file so my rgeos and rgdal installations work? Are there other errors I should expect to encounter and if so, how do I avoid/resolve them?
I also tried in a Terminal window:
conda install -c conda-forge r-rgdal
but that fails after spending a long time attempting to "solve environment":
Andrews-MacBook-Pro:~ aloha2018$ conda install -c conda-forge r-rgdal
Solving environment: failed
UnsatisfiableError: The following specifications were found to be in conflict:
- r-rgdal
- rstudio==1.1.423
Use "conda info <package>" to see the dependencies for each package.
So I try:
conda r-rgdal
But there is no output:
Andrews-MacBook-Pro:~ aloha2018$ conda info r-rgdal
Andrews-MacBook-Pro:~ aloha2018$
I've had a similar issue. I first solved it by installing everything using conda using the following environment.yml configuration
name: london-crime-r
channels:
- conda-forge
- conda
dependencies:
- gdal
- geos
- r-base
- r-rcpp
- r-irkernel
- r-mass
- r-dplyr
- r-rgdal
- r-rgeos
- r-raster
- rstudio
However, after updating conda, resolving dependencies did not finish within the 10 hours so I went the traditional route:
Use brew to install geos and gdal. It takes 40 minutes to build on my machine.
brew install geos gdal
Once that has been achieved, install R packages in this sequence.
install.packages('sp', type='source')
install.packages("rgeos", repos="http://R-Forge.R-project.org", type="source")
require(rgeos)
install.packages("rgdal", repos="http://R-Forge.R-project.org", type="source")
require(rgdal)
Subsequently, the packages below are ok with the plain install.
libraries <- c("rgdal",
"rgeos",
"raster",
"spdep",
"spatstat")
install.packages(libraries)
I am experiencing the same rJava problem that many other people seem to of had at one point or another. The error occurs when R CMD INSTALL tests whether JNI programs can be compiled.
The output recommends running R CMD javareconf -ed or sudo R CMD javareconf The output of the latter is :
computer: home$ sudo R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.6.0_31
Java home path : /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
Java library path:
JNI linker flags : -framework JavaVM
JNI cpp flags : -I$(JAVA_HOME)/include
Updating Java configuration in /Library/Frameworks/R.framework/Resources
Done.
And when trying to install rJava afterwards,
computer: home$ R CMD INSTALL ~/Downloads/rJava_0.9-4.tar.gz
* installing to library ‘/Library/Frameworks/R.framework/Versions/2.15/Resources/library’
* installing *source* package ‘rJava’ ...
checking for gcc... gcc -arch x86_64 -std=gnu99
checking for C compiler default output file name... a.out
/* Passes all checks */
configure: checking whether gcc -arch x86_64 -std=gnu99 supports static inline...yes
checking whether setjmp.h is POSIX.1 compatible... yes
checking whether sigsetjmp is declared... yes
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 : '-I/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/include'
java libs : '-framework JavaVM'
checking whether JNI programs can be compiled... configure: error: Cannot compile a simple JNI program. See config.log for details.
Make sure you have Java Development Kit installed and correctly registered in R.
If in doubt, re-run "R CMD javareconf" as root.
ERROR: configuration failed for package ‘rJava’
* removing ‘/Library/Frameworks/R.framework/Versions/2.15/Resources/library/rJava’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/2.15/Resources/library/rJava’
An alternative attempt where /usr/bin/javac is replaced by /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Homefails just the same.
I am running Mac OS 10.7.3 and
computer: home$ java -version
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04-415-11M3646)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01-415, mixed mode)
The following is in my .bash_profile
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Additionally, I have the same problem on Red-Hat. I hope any fix provided will work there too, but if it won't and why it won't is know, please explain.
I've been using this site's incredible knowledge base for a couple of years now, but this is my first post. Mucho thanks in advance.
Some (not all) of the resources I have already browsed through are
https://stat.ethz.ch/pipermail/r-devel/2008-November/051224.html
https://stat.ethz.ch/pipermail/r-help/2008-October/177688.html
R: rJava package install failing
Please note that the apt-get solution in the last link is of no use to me (I think) unless there is an equiv solution for port and/or yum.
I am using Redhat Linux 7.1
I was getting the same problem as above and I performed the following steps
1) Edit /usr/lib64/R/etc/Renviron and add "CPPFLAGS=${CPPFLAGS-'-ldl'}" to the end of the file
2) Then find the java home and set it like below ( set java home till /jre)
$export JAVA_HOME=/usr/lib/jvm/java-1.7.1-ibm-1.7.1.3.10-1jpp.1.el7_1.x86_64/jre
$export PATH=$PATH:$JAVA_HOME/bin
$R CMD javareconf
3) invoke R from commandline
$R
> install.packages("rJava")
> install.packages("RJDBC",dep=TRUE)
> q()
Save workspace image? [y/n/c]: y
I had a recent variation on this same problem with RHEL 6.5. I reviewed this thread and many others. The ptoblem was that the dynamic load modules were not found when testing the complile of the JNI programs. My fix was to insert "CPPFLAGS=${CPPFLAGS-'-ldl'}" into file
/usr/lib64/R/etc/Renviron