Compile R packages from source (Mac OS X) - r

I'm running Mac OS X 10.7.5 (Lion), which means that the latest version of R I can run is 3.2.1. Since binaries of packages are no longer being made for this version, it means that I need to install the latest package versions from source. I can do this with
install.packages(pkgs, type = "source")
I installed GNU Fortran, although it's not clear to me whether I need it or not in order to compile R packages.
When I try to compile packages from source in R, however, I get error messages indicating that I don't have (or that R cannot find) the necessary compiling tools. Cf. e.g.:
* installing *source* package ‘scales’ ...
** package ‘scales’ successfully unpacked and MD5 sums checked
** libs
sh: make: command not found
ERROR: compilation failed for package ‘scales’
and
* installing *source* package ‘stringi’ ...
** package ‘stringi’ successfully unpacked and MD5 sums checked
checking for local ICUDT_DIR... icu55/data
checking for R_HOME... /Library/Frameworks/R.framework/Resources
checking for R... /Library/Frameworks/R.framework/Resources/bin/R
checking for R >= 3.1.0 for C++11 use... yes
checking for R < 3.4.0 for CXX1X flag use... yes
checking for cat... /bin/cat
/Library/Frameworks/R.framework/Resources/bin/config: line 150: make: command not found
[...]
checking for gcc... no
checking for cc... no
checking for cl.exe... no
/Library/Frameworks/R.framework/Resources/bin/config: line 153: make: command not found
/Library/Frameworks/R.framework/Resources/bin/config: line 269: make: command not found
configure: error: in `/private/var/folders/2r/6c5vhb4s3zx3zs4d1dbf9p940000gn/T/Rtmpob4pMm/R.INSTALLd4676ad8595/stringi':
configure: error: no acceptable C compiler found in $PATH
I assume what's needed is to install the necessary compiling tools for R packages. What do I need to do?
(If I need to provide additional information, just ask for it in a comment, and I will provide it)

It might be tricky. First of all, double check whether you can download XCode from AppStore or not. If you can, you will be able to install command line tools as well. Either via Preferences -> Downloads (as far as I recall), or they will be installed during first startup.
Alternatively, create free account here:
http://developer.apple.com
Then, head to:
https://developer.apple.com/download/more/
and find XCode. It might be you will need to install some really old version.
As #hrbrmstr mentioned, it might be that installing virtual machine (e.g. inside VirtualBox) with Linux will be less painful.
Note that you will probably encounter more and more issues while installing packages. There is no easy way if you are forced to stick with old OS X :(
Update:
As #Sverre pointed out, it would be better to have a complete list of links here:
XCode - (Lion version) download from Apple (not to confuse with AppStore)
Command Line Tools - (Lion version) you can install them separately, without installing XCode

Related

Cannot find cairo.h

Common problem, but there's no solution for me so far - so maybe you can help a lost bioinformatician with rather little experience in IT stuff.
I need to install Cairo in my R environment (R version 4.1.1) on my mac Big Sur 11.5.1 and get this error:
> install.packages("Cairo")
...
checking for pkg-config... /usr/local/bin/pkg-config
checking whether pkg-config knows about cairo... no
configure: CAIRO_LIBS is unset, attempting to guess it.
configure: CAIRO_CFLAGS=
checking if R was compiled with the RConn patch... no
checking cairo.h usability... no
checking cairo.h presence... no
checking for cairo.h... no
configure: error: Cannot find cairo.h! Please install cairo (http://www.cairographics.org/) and/or set CAIRO_CFLAGS/LIBS correspondingly.
ERROR: configuration failed for package ‘Cairo’
* removing ‘/Users/thomaslordick/opt/anaconda3/envs/seurat4/lib/R/library/Cairo’
The downloaded source packages are in
‘/private/var/folders/48/5h26d5297_92l76cvyjqvk2h0000gp/T/RtmpD4g5aI/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warnmeldung:
In install.packages("Cairo") :
installation of package ‘Cairo’ had non-zero exit status
I already installed cairo-devel via sudo port install cairo, installed cairo via brew and also checked out similar threads (https://stat.ethz.ch/pipermail/r-help/2014-April/374096.html), where people recommend:
*Make sure you have cairo-devel installed, and remove the lines
export CAIRO_LIBS=${HOME}/usr/local/lib
export CAIRO_CFLAGS=${HOME}/usr/local/include
from your .bashrc file.*
I cant find a .bashrc file when using ls -la ~/... .
According to the above mentioned error I need to specify CAIRO_LIBS and CAIRO_CFLAGS. But where can I do this?
Thanks in advance,
Thomas
If using Conda for R environments, you are better off avoiding install.packages and instead make a point to always install through Conda. CRAN's Cairo package goes by r-cairo on Conda Forge. So,
conda install -n seurat4 -c conda-forge r-cairo

RQuantLib won't load when deploying a shiny app

I am having an issue when deploying a shiny app that requires the package RQuantLib. When I'm running my application, everything works fine, even the part where the RQuantLib package is needed. However, when deploying the application, the process is stopped when building the package RQuantLib.
When I put into comments the line "library(RQuantLib)" the application can be deployed but I am obviously missing my parts based on the use of this package.
Here's the error :
[2018-11-17T22:26:33.546919933+0000] Building R package: RQuantLib (0.4.5)
/mnt/packages/build /mnt
* installing to library ‘/opt/R/3.5.0/lib/R/library’
* installing *source* package ‘RQuantLib’ ...
** package ‘RQuantLib’ successfully unpacked and MD5 sums checked
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking for R... yes
checking for quantlib-config... yes
configure: WARNING: RQuantLib requires QuantLib (>= 1.8.0).
configure: error: Please upgrade to a current version.
ERROR: configuration failed for package ‘RQuantLib’
* removing
‘/opt/R/3.5.0/lib/R/library/RQuantLib’################################# End
Task Log #################################
Erreur : Unhandled Exception: Child Task 565972976 failed: Error building
image: Error building RQuantLib (0.4.5). Build exited with non-zero status:
1
De plus : Warning message:
Error detecting locale: Error in read.table(file = file, header = header,
sep = sep, quote = quote, : incomplete final line found by readTableHeader
on 'raw'
(Using default: en_US)
Thank you in advance !
RQuantLib author here. I actually try to make this as plain as I can:
configure: WARNING: RQuantLib requires QuantLib (>= 1.8.0).
configure: error: Please upgrade to a current version.
ERROR: configuration failed for package ‘RQuantLib’
Also not sure what system you are on (as you didn't say) but both Debian and Ubuntu
have RQuantLib natively: sudo apt install r-cran-rquantlib is all it takes.
Otherwise it may be worth re-stating the somewhat obvious: to build RQuantLib from source you need both R and QuantLib on the system you are building (== installing) on if you install from source. Hence the attractiveness of installing binaries -- which I provide as Debian maintainer.

linux redhat gsl R installation error: cannot run C compiled programs.

I was trying to install the R gsl wrapper in our university's HPC cluster, with R version 3.1.1 and OS x86_64-redhat-linux-gnu (64-bit). But something weird happened:
R CMD INSTALL '/d1/pyangac/gsl_1.9-10.1.tar.gz'
* installing to library /d1/pyangac/R_libs/ installing *source* package gsl...
** package gsl successfully unpacked and MD5 sums checked
checking for gsl-config... /usr/local/gsl-1.16/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... 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 gsl
* removing /d1/pyangac/R_libs/gsl
Here are some specifics I have made before I run the installation command. There are two gsl libraries already installed in the cluster, one is gsl, and the other is gsl-1.16 (version 1.16). As the R gsl wrapper requires external gsl library version >= 1.12, before installation, I have set the environments LDFLAGS="-L/usr/local/gsl-1.16/lib -lgsl -lgslcblas -lm"; export LDFLAGS and CPPFALGS="-I/usr/local/gsl-1.16/include"; export CPPFLAGS, so that R will install the wrapper based on version 1.16. I also added the following two paths to make sure R will find the gsl-config file export PATH=$PATH:/usr/local/gsl-1.16, and export PATH=$PATH:/usr/local/gsl-1.16/bin.
Then I run the previous installation command and the error suggests that the C compiler cannot work. After some searches I think it may be caused by the fact that the gsl library is not in the gcc include directory. After typing the following commands, I think the problem would be solved:
export CPATH=/usr/local/gsl-1.16/include
Unfortunately, when I reinstall the gsl wrapper, the same 'cannot run C compiled programs' error appears again. Sorry that I can't provide any further information, as I cannot find the config.log file.
Does anyone has any hint why this is happening, or how to find the config.log file?
Thanks.
checking whether the C compiler works... configure: error: cannot run
C compiled programs
# yum install gcc-c++
I.e. the install of gcc-c++ will also install the dependencies that make gcc work. ( The gcc missing parts are { glibc-devel, glibc-headers, linux-headers } → /usr/lib64/[files], /usr/include/[files].h )

How to install rgdal and rgeos package in R on university high performance computing system?

I have been installing R packages from tar.gz type files on Edinburgh university's compute and data facility which is a high performance computing cluster which is accessed via SSH. Once logged in, I can install the files as the example below:
install.packages("/exports/work/eng_AntonyHydroData/Pkges/DEoptim_2.2-3.tar.gz",rpeo=NULL,target="source")
There are approximately 40 packages and 38 of them install no problem, but two fail: RGEOS (rgeos_0.3-14.tar.gz) and RGDAL (rgdal_1.0-7.tar.gz).
The reason for failure is given below:
Installing package into '/exports/work/eng_AntonyHydroData/library'
(as 'lib' is unspecified)
inferring 'repos = NULL' from 'pkgs'
* installing *source* package 'rgdal' ...
** package 'rgdal' successfully unpacked and MD5 sums checked
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: rgdal: 1.0-5
checking for /usr/bin/svnversion... yes
configure: svn revision: 559
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package 'rgdal'
Note that RGEOS gives the same reason i.e. gdal-config is missing.
I have looked around the net and have found various answers to this problem that mainly suggests to install libgeos-dev or something similar using the command 'sudo' or 'apt-get' but neither of these commands are recognised by the computing cluster system.
Any help in getting RGEOS and RGDAL to work would be very much appreciated.
Antony
I managed to solve this by first installing the geos-3.5.0.tar.bz2 package and issuing the following linux commands:
tar xjvf geos-3.5.0.tar.bz2
cd geos-3.5.0
./configure --help
mkdir /exports/work/....
./configure --help,
./configure --prefix=eng_A... --enable-python
make
make check
make install
and similar for rgdal
I'm not sure how your HPC system is setup but as the previous comment implied, you need "geos" installed/loaded. The system I work on uses the "module" command to load programs, so I use "module available" to find where "geos" is on the system so you can load it.
Here's an example from another system: http://docs.hpc.shef.ac.uk/en/latest/iceberg/software/apps/r.html

OSX - Can't configure rgdal for install

So I've been through a few problems trying to install rgdal. I'm running OS X 10.10.4
First I tried installing it from R :
install.packages("rgdal")
but the config file was not found :
configure: error: gdal-config not found or not executable.
So I installed gdal using Homebrew :
brew install gdal
Which installed a few dependencies alongside, like proj.
Problem is, R still can't install rgdal :
configure: error: proj_api.h not found in standard or given locations.
So I tried installing it manually, copying the rgdal_1.0-7.tar.gz from the temporary downloaded sources and unzipping it.
As ./config still seemed to fail finding proj_api.h, I searched it on my computer and found out it was in /usr/local/Cellar/proj/4.9.1/include, I tried
./configure CPPFLAGS="-I/usr/local/Cellar/proj/4.9.1/include"
... but it still doesn't work.
Now configure finds proj_api.h, but seems to be unable to find the functions defined in this header :
checking for proj_api.h... yes
checking for pj_init_plus in -lproj... no
configure: error: libproj not found in standard or given locations.
So now I don't know what to do anymore.
Any help would be great :)

Resources