RStudio can't install "igraph" - C compiler cannot create executables - r

Im using anaconda, so RStudio 1.1.456.
When I try to
install.packages("igraph")
I get this message:
trying URL 'https://cran.rstudio.com/src/contrib/igraph_1.2.4.1.tar.gz'
Content type 'application/x-gzip' length 2704004 bytes (2.6 MB)
==================================================
downloaded 2.6 MB
* installing *source* package ‘igraph’ ...
** package ‘igraph’ 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/x1/zlhhtxm951v95d461h7d09bc0000gn/T/Rtmp0iNakh/R.INSTALL16a5d3eb16782/igraph':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘igraph’
* removing ‘/Users/RobinHorn/anaconda3/envs/Data_Analysis/lib/R/library/igraph’
Warning in install.packages :
installation of package ‘igraph’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/x1/zlhhtxm951v95d461h7d09bc0000gn/T/RtmpYbzkOw/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
So it looks like my C compiler is not working.
What I tried already:
installing command line tools
xcode-select --install
installing missing headers:
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
This results in:
installer: Error - the package path specified was invalid: '/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg'.
gcc seems to be installed correctly:
~ % 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.12)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
~ %

I ran across your post because I had the same problem. My answer hinges on one question: do you really need to access RStudio through Anaconda? If your answer is "no," then the solution is simple:
I downloaded RStudio from rstudio.com and installed it directly on my Mac; the version happens to be 1.2.5033. Now when I install
install.packages("igraph")
everything works fine. I have tested several functions with no problem (but don't forget to load the package).
Note that when I return to RStudio through Anaconda, it still does not work. Apparently, Anaconda keeps its own copy of the install tree but does not play nicely with certain packages ...

Related

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

Error when install 'e1071' in R on Mac

Error shown on console
> install.packages('e1071')
trying URL 'https://cran.rstudio.com/src/contrib/e1071_1.6-8.tar.gz'
Content type 'application/x-gzip' length 581513 bytes (567 KB)
==================================================
downloaded 567 KB
* installing *source* package ‘e1071’ ...
** package ‘e1071’ successfully unpacked and MD5 sums checked
checking for C++ compiler default output file name... a.out
checking whether the C++ compiler works... configure: error: cannot
run C++ compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.
ERROR: configuration failed for package ‘e1071’
* removing ‘/anaconda3/lib/R/library/e1071’
Warning in install.packages :
installation of package ‘e1071’ had non-zero exit status
I've checked on terminal, gcc is installed and updated.
I also tried https://cran.r-project.org/web/packages/e1071/index.html to download both latest and former versions manually and installed them on R console. The error was still there.
How can I fix it?
Thanks!
I ran into this error when using RStudio through Anaconda. I just re-downloaded RStudio from the R website, and now the error has gone away, and e1071 installs just fine.

Installing RGtk2 on macOS Sierra (Version 10.12.4) and R version 3.4.0

When I try to install the package RGtk2 I get the following error:
> install.packages("RGtk2")
Package which is only available in source form, and may need
compilation of C/C++/Fortran: ‘RGtk2’
Do you want to attempt to install these from sources?
y/n: y
installing the source package ‘RGtk2’
trying URL 'https://cran.rstudio.com/src/contrib/RGtk2_2.20.33.tar.gz'
Content type 'application/x-gzip' length 2792938 bytes (2.7 MB)
==================================================
downloaded 2.7 MB
* installing *source* package ‘RGtk2’ ...
** package ‘RGtk2’ successfully unpacked and MD5 sums checked
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for INTROSPECTION... no
checking for GTK... no
configure: error: GTK version 2.8.0 required
ERROR: configuration failed for package ‘RGtk2’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/RGtk2’
Warning in install.packages :
installation of package ‘RGtk2’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/m4/l02774c51vx71qt6_wdq59lw0000gn/T/Rtmpa7sxIS/downloaded_packages’
>
I am running macOS Sierra (Version 10.12.4) and R version 3.4.0.
I assume you have R and RStudio installed already. If not, install it. Then do the following.
1) Install XQuartz
2) Install GTK 2.24.17-X11
3) Download cairoDevice and RGtk2
4) From terminal run R CMD INSTALL ~/Downloads/cairoDevice_2.24.tar.gz
5) Install Homebrew for Mac.
6) From terminal type the following commands:
brew uninstall cairo --ignore-dependencies
brew install --with-x11 cairo
7) Type brew edit gtk+ in terminal and scroll to def install section and edit the reference with quartz to (press i to edit and to save and exit, press escape key and type colon (shift+ semi colon key). Then type wq.)
"--with-gdktarget=x11",
"--enable-x11-backend"
8) Then type brew install --build-from-source --verbose gtk+ in the same terminal window.
9) Then type export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib/pkgconfig/gtk+-2.0.pc:/opt/X11/lib/pkgconfig
10) Type R CMD INSTALL ~/Downloads/RGtk2_2.20.33.tar.gz from the same terminal window.
Hopefully it will work for you.
You probably don't have GTK installed in your system (outside of R). You can try an install from the GTK package in the ../libs/ directory here:
http://r.research.att.com/libs/
Probably need XQuartz, Xcode of the proper version for your macOS version and the correct Command Line Tools first. The download and install code for the bash-install are at the bottom of that /libs/ page.
when I tried to install RGtk2 this comes up... I checked which gcc and it shows a c compiler. why does it say that C compiler is not working?
$ R CMD INSTALL ~/Downloads/RGtk2_2.20.33.tar.gz
* installing to library ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library’
* installing *source* package ‘RGtk2’ ...
** package ‘RGtk2’ successfully unpacked and MD5 sums checked
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for INTROSPECTION... no
checking for GTK... yes
checking for GTHREAD... yes
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/private/var/folders/xh/kw0cr4xj52zd9pd8t46d6xwh0000gn/T/RtmpnYEC6D/R.INSTALL13a7b3357df80/RGtk2':
configure: error: C compiler cannot create executables
See `config.log' for more details.
ERROR: configuration failed for package ‘RGtk2’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/RGtk2’
Following the directions on this website will likely be helpful: https://gist.github.com/sebkopf/9405675.
Be sure to read the additional conversations after the post for useful modifications.

installing R gsl package on Mac

I'm trying to install the gsl package for R, which I understand is simply a wrapper around the GSL, under OSX Mavericks. I've tried the obvious:
> install.packages('gsl')
Installing package into ‘/Users/myusername/Library/R/3.1/library’
(as ‘lib’ is unspecified)
package ‘gsl’ is available as a source package but not as a binary
Warning in install.packages :
package ‘gsl’ is not available (for R version 3.1.0)
So I ran
> install.packages('gsl',type = 'source')
Installing package into ‘/Users/myusername/Library/R/3.1/library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/gsl_1.9-10.tar.gz'
Content type 'application/x-gzip' length 342803 bytes (334 Kb)
opened URL
==================================================
downloaded 334 Kb
* installing *source* package ‘gsl’ ...
** package ‘gsl’ successfully unpacked and MD5 sums checked
checking for gsl-config... no
configure: error: gsl-config not found, is GSL installed?
ERROR: configuration failed for package ‘gsl’
* removing ‘/Users/myusername/Library/R/3.1/library/gsl’
Warning in install.packages :
installation of package ‘gsl’ had non-zero exit status
No GSL install. D'oh! So I install GSL via Homebrew:
~ brew install gsl
==> Downloading http://ftpmirror.gnu.org/gsl/gsl-1.15.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/gsl/1.15
==> make
==> make install
/usr/local/Cellar/gsl/1.15: 239 files, 6.7M, built in 101 seconds
Try to install the R package again:
> install.packages('gsl',type = 'source')
Installing package into ‘/Users/myusername/Library/R/3.1/library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/gsl_1.9-10.tar.gz'
Content type 'application/x-gzip' length 342803 bytes (334 Kb)
opened URL
==================================================
downloaded 334 Kb
* installing *source* package ‘gsl’ ...
** package ‘gsl’ successfully unpacked and MD5 sums checked
checking for gsl-config... /usr/local/bin/gsl-config
checking if GSL version >= 1.12... 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 suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
configure: error: Need GSL version >= 1.12
ERROR: configuration failed for package ‘gsl’
* removing ‘/Users/myusername/Library/R/3.1/library/gsl’
Warning in install.packages :
installation of package ‘gsl’ had non-zero exit status
I'm obviously going about this the wrong way but am unsure about where exactly the problem lies.
I was able to get things working (OS X Yosemite 10.10, R 3.1.1, gsl 1.16, gsl R package 1.9-10) with standard brew-installed R and gsl by manually prefixing CFLAGS and LDFLAGS with the output from gsl-config --cflags and gsl-config --libs respectively.
The following:
CFLAGS="-I/usr/local/opt/gsl/include" LDFLAGS="-L/usr/local/opt/gsl/lib -lgsl -lgslcblas" R
...
> install.packages("gsl")
worked for me.
Note that gsl-config lists the direct path to my Cellar, the paths above are brew symlinks.
For Mac, just run:
brew install gsl
then install the package in r
I finally got this to work though I'm not sure which parts of the following are absolutely essential. Here's a step-by-step list of instructions:
(steps in parentheses may be optional. Perhaps the whole thing works with homebrew)
(download the latest version of the GSL from http://ftp.gnu.org/gnu/gsl/ (as of this writing the file to get is gsl-1.16.tar.gz))
(open up a terminal window, untar the file, cd into the directory and then run ./configure, make and make install)
download the sources to the R package from http://cran.r-project.org/web/packages/gsl/index.html
open up a terminal window and run launchctl setenv PATH "/usr/local/bin:$PATH"
in the same terminal window, build the R package (I couldn't get this to work from within R) by untar'ing the file just downloaded, cding into the directory and then running R CMD build ./gsl and R CMD INSTALL gsl_1.9-10.tar.gz
Note to self: On Debian, to fix
checking for gsl-config... no
configure: error: gsl-config not found, is GSL installed?
I needed to
sudo apt-get install libgsl-dev
Note that the package name on Debian is not gsl-devel as elsewhere. Sigh.
I believe that others will find your steps successful and I think they do need to be done in that order. The build of gsl from source does need to be done after adding the homebrew default directory to the path. If you had used the binary, it was built on a CRAN machine that was able to find the (external) GSL package in the expected directy (which is not the default for homebreww installations. You might have succeeded with `install.packages('gsl_1.9-10.tar.gz', repo=NULL, type="source") if the source package were in your working directory (or add the full path/name as the first argument.) Just as with using Terminal, if you click-hold-drag a file to the R console, you will get a text entry of the full path/name.
gsl-config in included with the gsl-devel package, try installing that. After that it should work
On OS X Mavericks at least, after installing gsl via brew install gsl, the gsl-config --prefix yields /usr/local/Cellar/gsl/1.16. However, many applications/libraries like gsll for Common Lisp (in my case) expect /usr/local/Cellar/gsl/1.16/lib instead. In my case, the super lazy (long-term unacceptable) solution was just to symlink the libs from /usr/local/Cellar/gsl/1.16/lib into /usr/local/Cellar/gsl/1.16 and all was well. Hope this helps.

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