package installation C++ compiler does not work R - r

I would like to install a package from my local environment. I have a mac and tried with both R 4.0.0 and R 3.6.3 and encounter the same issues with both R versions. When installing the package I get the following error and I do not know what to make out of this. Can anyone help interpreting it and suggest possible sources for this problem?
* installing *source* package ‘package’ ...
** using staged installation
checking whether the C++ compiler works... no
configure: error: in `/private/tmp/RtmpCtsuxn/R.INSTALL3d701f92995/goldfish':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘package’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/package’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/package’
Warning in install.packages :
installation of package ‘/Users/simon/Downloads/package_1.4.1.tar’ had non-zero exit status

Related

rgl installation in Mac: X11 not found

I am having the same problem as this and this.
I have installed R and rstudio through a conda environment which included r-rgl. I am now trying to install a package within R that requires rgl. However, calling library(rgl) gives the error
Error: package or namespace load failed for ‘rgl’:
package ‘rgl’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version
I have tried to install rgl from within R, but then I get this message:
checking for X... no
configure: error: X11 not found but required, configure aborted.
ERROR: configuration failed for package ‘rgl’
* removing ‘/path/to/miniconda3/envs/my_conda_env/lib/R/library/rgl’
* restoring previous ‘/path/to/miniconda3/envs/my_conda_env/lib/R/library/rgl’
Warning in install.packages :
installation of package ‘rgl’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/vh/.../downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
The solution to the last error seems to be installing XQuartz in Mac, but I had it installed before. So I tried specifying install.packages("rgl", INSTALL_opts = "--with-libpng-prefix=/usr/X11/") but I still get the error above. Any suggestions? I'm quite lost now...
TL;DR: how do I connect my XQuartz installation with each conda environment that I create?

Error with install.packages() for R on ubuntu 16.04

I recently installed R on Ubuntu 16.04 and tried installing a package that I need:
install.packages('gimme')
The dependencies seem to download fine but their installation is where the errors pop. Even tho g++ is installed for example, R can't seem to use it:
* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
checking for g++... no
checking for c++... no
checking for gpp... gpp
checking whether the C++ compiler works... no
configure: error: in `/tmp/Rtmpq1Yg7t/R.INSTALLedf3b8432e7/nloptr':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘nloptr’
* removing ‘/usr/local/lib/R/site-library/nloptr’
From what I can tell it looks like R can't find the compilers on my system, but I can't seem to find out how to fix this. I installed the package on a windows machine just fine.
Any experience setting up and installing R packages on Ubuntu?
apt-get install --reinstall g++
made all the difference. was missing the --reinstall flag

'termstrc' was removed from CRAN, tried installing from .tar file - how do I install 'termstrc' I need it for another program

* installing *source* package 'termstrc' ...
** libs
*** arch - i386
Warning in system(cmd) : 'make' not found
ERROR: compilation failed for package 'termstrc'
* removing 'C:/Program Files/R/R-3.5.1/library/termstrc'
In R CMD INSTALL
Warning in install.packages :
installation of package ‘C:/Users/DANIEL~1/DOWNLO~1/termstrc_1.3.7 (1).tar.gz’ had non-zero exit status
If you want to build R packages from source, you need to have the proper tools like compiler etc. installed. You seem to be using Windows, which is particularly difficult in that respect. The necessary tools have therefore been collected as Rtools package: https://cran.r-project.org/bin/windows/Rtools/. You will have to install that in order to build the package.

Unable to install xlsx package in Rstudio

I tried installing xlsx package in R.
install.packages("xlsx")
installing *source* package 'xlsx' ...
** package 'xlsx' successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
*** arch - i386
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures.
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Users/hi/Documents/R/win-library/3.3/xlsx'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-33~1.2/bin/x64/R" CMD INSTALL -l "C:\Users\hi\Documents\R\win-library\3.3" C:\Users\hi\AppData\Local\Temp\RtmpSGp15V/downloaded_packages/xlsx_0.6.1.tar.gz' had status 1
Warning in install.packages :
installation of package ‘xlsx’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\hi\AppData\Local\Temp\RtmpSGp15V\downloaded_packages’
Then I ran the library function too
library(xlsx)
Error in library(xlsx) : there is no package called ‘xlsx’
To ensure that whether the package has been installed itself or not I ran
grepl("xlsx",installed.packages())
# It returns "FALSE" 649 times in a row.
I read online about how some rjava packages need to be installed as well so I tried to
install.packages('rJava')
install.packages("xlsxjars")
package ‘rJava’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\hi\AppData\Local\Temp\RtmpSGp15V\downloaded_packages
To ensure grepl("rJava",installed.packages())
Again I got "FALSE" 649 times.
I recently had a similar problem with another package and have had loads of headaches with R and Java integration. My understanding is that you have to install Java for each architecture you're using. If R is trying to install xlsx for both architectures and you've only got the 64-bit java installed, it would cause a failure like the one you got. You could try:
install.packages("xlsx", INSTALL_opts=c("--no-multiarch"))
This would keep it from trying to install the xlsx for the 32-bit architecture.
I had the same problem a few months ago. In my case, the solution was installing both versions of java (32-bit and 64-bit architecture). On windows 10 the 32-bit architecture should be installed on path ./programfiles (x86)/... and the 64-bit architecture should be installed on ./programfiles/... Both java installer can be found on the official web page.
After installing both architectures of java, it is necessary to make sure that JAVA HOME environtment is declared as empty string. Sys.getenv("JAVA HOME") = "".
This steps works for me. I hope that my solution works for you.

error installing RandForestGUI (hence 'rgl', 'X11) in "R version 2.13.1 (2011-07-08)"

I have installed "R version 2.13.1 (2011-07-08)", over "Ubuntu 10.04 - Lucid Lynx".
(I use RStudio 0.94.92), with all the headers needed to compile the many different packages I already installed.
I got stuck with : install.packages("RandForestGUI"). Everything ran smoothly until
.....
* DONE (sciplot)
ERROR: dependency ‘rgl’ is not available for package ‘clusterSim’
* removing ‘/home/rs/R/i486-pc-linux-gnu-library/2.13/clusterSim’
Warning in install.packages :
installation of package 'clusterSim' had non-zero exit status
ERROR: dependency ‘clusterSim’ is not available for package ‘RandForestGUI’
* removing ‘/home/rs/R/i486-pc-linux-gnu-library/2.13/RandForestGUI’
Warning in install.packages :
installation of package 'RandForestGUI' had non-zero exit status
I tried to : install.packages("rgl") but
Installing package(s) into ‘/home/rs/R/i486-pc-linux-gnu-library/2.13’
(as ‘lib’ is unspecified)
provo con l'URL 'http://rm.mirror.garr.it/mirrors/CRAN/src/contrib/rgl_0.92.798.tar.gz'
Content type 'application/x-gzip' length 1677772 bytes (1.6 Mb)
URL aperto
==================================================
downloaded 1.6 Mb
* installing *source* package ‘rgl’ ...
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
….
checking for libpng-config... yes
configure: using libpng-config
configure: using libpng dynamic linkage
checking for X... no
configure: error: X11 not found but required, configure aborted.
ERROR: configuration failed for package ‘rgl’
* removing ‘/home/rs/R/i486-pc-linux-gnu-library/2.13/rgl’
Warning in install.packages :
installation of package 'rgl' had non-zero exit status
Finally I tried : install.packages("X11") and
Installing package(s) into ‘/home/rs/R/i486-pc-linux-gnu-library/2.13’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘X11’ is not available (for R version 2.13.1)
... was stuck!.
Is it possible to have RandForestGUI in "R version 2.13.1 (2011-07-08)"?
Many thanks, Roberto Scotti
Couple of rerequisites:
Use an R binary from the CRAN Ubuntu repository.
Do sudo apt-get install r-base-dev to complement your R environment for local package installation if you haven't already done so.
Then do sudo apt-get install r-cran-rgl as that is the hardest one to OpenGL headers.
Now try again with the RForestGUI package and its other dependants, and analyse the errors package by package.
The error indicates that you don't have the relevant X11 headers package for your OS. This is not an R package. You need to install that using whatever tools Ubuntu provides (as it is a Debian off-shoot, apt get should work, but there may be other, preferred techniques for adding packages to your OS.
The R Installation and Administration manual suggests that, for Debian, the relevant OS package needed is xorg-dev. Try installing that using your package manager in Ubuntu, and retry to install rgl inside R.
#Dirk Eddelbuettel will no doubt comment that there are pre-built packages in Ubuntu for many of R's packages or at least a meta-package for R Development that will make sure you have all the header packages for your OS available so you can build R packages at install time. I don't use Ubuntu or Debian so I cannot help with this aspect of your Q.
Had a similar problem for the clusterSim package in OS X.
Found the solution on the rstudio board:
X11 isn't installed by default on newer versions of OS X, so I had to install Quartz (the osx distribution of X11)

Resources