stringi install error: configure: error: C compiler cannot create executables - r

I am trying to install stringi package after a recent update of R to newest version. However, I met this error:
* installing *source* package ‘stringi’ ...
** package ‘stringi’ successfully unpacked and MD5 sums checked
checking for local ICUDT_DIR... icu55/data
checking for R_HOME... /usr/local/Cellar/r/3.4.3/lib/R
checking for R... /usr/local/Cellar/r/3.4.3/lib/R/bin/R
checking for R >= 3.1.0 for C++11 use... yes
checking for R < 3.4.0 for CXX1X flag use... no
checking for cat... /bin/cat
checking for gcc... /usr/local/opt/llvm/bin/clang -fopenmp
checking whether the C compiler works... no
configure: error: in `/private/var/folders/y5/m7pd62wn3939vyqxygrd_ff80000gn/T/RtmpNBCRW2/R.INSTALL8ec750ee123/stringi':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘stringi’
* removing ‘/usr/local/lib/R/3.4/site-library/stringi’
Warning in install.packages :
installation of package ‘stringi’ had non-zero exit status
Following some posts, I tried:
install.packages('stringi', configure.args='--disable-cxx11')
or:
install.packages('stringi', type='mac.binary')
How could I correctly install stringi, did I miss something?
Additional info: I updated R with Homebrew. I successfully installed data.table before trying to install stringi, therefore it seems to be caused by package-specific problem.
Here is my session info:
R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin17.2.0 (64-bit)
Running under: macOS High Sierra 10.13.2
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.3 tools_3.4.3

I got the same problem when updating the stringi package. As was stated here https://github.com/gagolews/stringi/issues/291, the issue wasn't with stringi but instead in ~/.R/Makevars. Installation was successful upon deleting this file using rm ~/.R/Makevars in your command line.

I have no idea about what caused the error. But finally I was able to install stringi through following steps:
remove all versions of R installed by homebrew with: brew uninstall --force r
download gfortran(not sure whether this is necessary, just following the installation guide in manual) and R 3.4.3 for Mac OS X from CRAN (I chose .pkg, while .dmg files are also available) and install them.
open studio and run install.packages('stringi'), which seems installed the binary package successfully.

Upgrade you compiler, here is an example works on openSUSE:
install newer version of compiler:
zypper in gcc7 gcc7-c++ gcc7-c++ gcc7-fortran
Edit your compiler config files, open /usr/lib64/R/etc/Makeconf, and add following content:
CC = gcc-7
CXX = g++-7
CXX98 = g++-7
CXX11 = g++-7
CXX14 = g++-7
CXX17 = g++-7
FC = gfortran-7
F77 = gfortran-7
Theoretically, you do not need to restart your R, just install the package you need directly.
Happy coding ;)

If you are on MacOS your xcode license might be expired. Try running:
sudo xcodebuild -license
from the command line and agreeing with the license.

Related

gdal-config not found while installing packages, Mac M1 Ventura

I am trying to install some packages to work with spatial data such as sf, stars, rgdal, on a Mac Book Air M1 with Ventura.
To do so, I need to have gdal installed to my compute, which I have. My problem is that when I try to install a library (see example with sf here below), the gdal-config file is not found.
But I have it on my computer, so my question is :
Is there a way to indicate the path to R to find that file ?
I tried to to uninstall and reinstall gdal with homebrew, I have proj that is also a dependency rightly installed.
I need to install from sf from sources as it is needed to install the stars package.
(base)#MacBook-Air ~ % echo $PATH
/opt/homebrew/bin:/opt/anaconda3/bin:/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
(base)#MacBook-Air ~ % whereis gdal-config
gdal-config: /opt/homebrew/bin/gdal-config /opt/homebrew/share/man/man1/gdal-config.1
(base)#MacBook-Air ~ % gdal-config
Usage: gdal-config [OPTIONS]
Options:
[--prefix[=DIR]]
[--libs]
[--dep-libs]
[--cflags]
[--datadir]
[--version]
[--ogr-enabled]
[--gnm-enabled]
[--formats]
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 13.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.3 tools_4.0.3
(base)#MacBook-Air ~ % proj
DeprecationWarning: PROJ_LIB environment variable is deprecated, and will be removed in a future release. You are encouraged to set PROJ_DATA instead.
Rel. 9.1.1, December 1st, 2022
usage: proj [-bdeEfiIlmorsStTvVwW [args]] [+opt[=arg] ...] [file ...]
P.S: I know there are a lots of related topics (Error: gdal-config not found while installing R dependent packages whereas gdal is installed), but all of them are on Linux, and the solutions are not working for me on Mac machine.
I solved it by reinstalling the latest version of R and R Studio.

Compile R packages from source on macOS Big Sur running on ARM silicon

When trying to compile R packages from source I ran into one of the following errors:
make: gfortran-11: No such file or directory
configure: error: C compiler cannot create executables
My setup
Installed Homebrew which seems to now live under /opt/homebrew instead of /usr/local (see "This script installs Homebrew to its preferred prefix (/usr/local for macOS Intel, /opt/homebrew for Apple Silicon [...]")
Installed Xcode and the CLI "the manual way" as described here
Installed brew install gcc
Created ./R/Makevars with the following content (which I don't understand and puzzled together from various posts):
VER=-11
CC=gcc$(VER)
CXX=g++$(VER)
CXX11=g++$(VER)
CXX14=g++$(VER)
CXX17=g++$(VER)
CFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
CXXFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
FLIBS=-L/opt/homebrew/Cellar/gcc/11.2.0/lib/gcc/11
FC=gfortran$(VER)
CPPFLAGS += -Xclang -fopenmp
LDFLAGS += -lomp
As suggested in the thread of this GitHub issue, I also created $R_HOME/etc/Makevars with the identical content of ./R/Makevars
Then I ran `install.packages("igraph", type = "source") and currently get the following result:
> install.packages("igraph", type = "source")
trying URL 'https://cran.rstudio.com/src/contrib/igraph_1.2.6.tar.gz'
Content type 'application/x-gzip' length 2715500 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... gcc-11
checking whether the C compiler works... no
configure: error: in `/private/var/folders/ry/bnfxqrqd1bd4mxtvgvnsr9j80000gn/T/Rtmp5mvh5Q/R.INSTALL31ea32410e8e/igraph':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘igraph’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/igraph’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/igraph’
Warning in install.packages :
installation of package ‘igraph’ had non-zero exit status
Here is a summary of what I think I learned/understood so far and what I still need to figure out.
System info
Big Sur 11.6
Homebrew 3.2.14
Xcode 13
R 4.0.5
sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 11.6
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
loaded via a namespace (and not attached):
[1] compiler_4.0.5 htmltools_0.5.1.1 tools_4.0.5
[4] yaml_2.2.1 rmarkdown_2.8 knitr_1.33
[7] xfun_0.23 digest_0.6.27 rlang_0.4.11
[10] evaluate_0.14
DISCLAIMER
I'm pretty new to the macOS world in general and pretty much know nothing about compilers, C or Fortran - so please explain things to me like you would to your rubber duck or a 5 year old ;-)

R Compind package double free or corruption (out) Aborted (core dumped)

I have bumped in this error,
but I have no idea how to investigate if it is related to my c++ packages or is the Compind package.
Thank you
**install.packages("Compind", dependencies=TRUE)
** byte-compile and prepare package for lazy loading
double free or corruption (out)
Aborted (core dumped)
ERROR: lazy loading failed for package ‘Compind’
* removing ‘/home/user/R/x86_64-pc-linux-gnu-library/4.1/Compind’
The downloaded source packages are in
‘/tmp/RtmpHSWH4g/downloaded_packages’
Warning message:
In install.packages("Compind", dependencies = TRUE) :
installation of package ‘Compind’ had non-zero exit status
> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3
You should avoid compiling packages yourself if possible. Add the cran2deb4ubuntu 4.0 PPA and then install via apt-get.
That looks like a problem with a system library. The problem will be that Compind doesn't declare any, so it is likely an issue with one of its many dependencies.
I'd try update.packages(ask=FALSE, checkBuilt=TRUE) first, to make sure the dependencies are up to date. If that doesn't fix the problem, you'll probably have to run R under a debugger to get more info. On Linux, I think you can do that with
R -d gdb
as long as you know how gdb works.

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 rebuild the 'indexing' package on MAC OSX

I am trying to install 'indexing' package in r: R-Forge
However, It says it is "failed to build" & am looking for a way to fix this? I do not see a download option for the package.... I am currently on MAC OSX Yosemite and trying to load this in the latest R-Studio.
R version 3.1.2 (2014-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
When trying to load via r-studio:
install.packages("indexing", repos="http://R-Forge.R-project.org")
> source repository is unavailable to check versions
> Error in install.packages : Line starting '<!DOCTYPE HTML PUBLI ...' is malformed!
Even though the download link on R-forge doesn't appear to work any more (it may say not available for version >= 3.3. etc), you can still install indexing from source on OSX (or any other operating system).
Open a new terminal in OS X, and in a directly of your choice type the following to install indexing:
svn checkout svn://svn.r-forge.r-project.org/svnroot/indexing/
If you did this correctly, type ls in the terminal and you should see a new directory called indexing. Inside this directory is the source code you need to build the indexing package.
Without changing from the current directory, install the dependency R package mmap if you don't already have it (you might have already installed in from CRAN, in which case you may be able to skip this step) with:
R CMD INSTALL indexing/pkg/mmap
Finally, install indexing from source
R CMD INSTALL indexing/pkg/indexing
You should see something like this in the terminal output if successful:
* installing to library ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library’
* installing *source* package ‘indexing’ ...
** libs
make: Nothing to be done for `all'.
installing to /Library/Frameworks/R.framework/Versions/3.3/Resources/library/indexing/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (indexing)
Enjoy!

Resources