Search code examples
linuxgccrcppr-packagestringi

configure: error: C++ compiler cannot create executables when installing R package 'stringi' and 'RcppDist'


I wanted to install stringi and RcppDist package at first.install.packages("stringi") But I get some problems with C++ compiler, it doesn't work properly although I've searched for almost every solutions I can find online.

Installing package into '/data/gongyixi/R/x86_64-conda-linux-gnu-library/4.0'
(as 'lib' is unspecified)
URL’https://cran.rstudio.com/src/contrib/stringi_1.8.3.tar.gz'
Content type 'application/x-gzip' length 11917752 bytes (11.4 MB)
==================================================
downloaded 11.4 MB

* installing *source* package ‘stringi’ ...
** successfully ‘stringi’ MD5 checked
** using staged installation
checking for R_HOME... /public/home/maintain/miniconda3/lib/R
checking for R... /public/home/maintain/miniconda3/lib/R/bin/R
checking for endianness... little
checking for cat... /usr/bin/cat
checking whether the C++ compiler works... no
configure: error: in `/tmp/RtmpPkzeqM/R.INSTALL3fa654dfb9ee6/stringi':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘stringi’
* removing ‘/data/gongyixi/R/x86_64-conda-linux-gnu-library/4.0/stringi’
Warning in install.packages :
  installation of package 'stringi' had non-zero exit status

The downloaded source packages are in
    '/tmp/Rtmpmip14o/downloaded_packages'

I checked the config.log to see what's wrong.

## ----------- ##
## Core tests. ##
## ----------- ##

configure:2395: checking for R_HOME
configure:2406: result: /public/home/maintain/miniconda3/lib/R
configure:2412: checking for R
configure:2422: result: /public/home/maintain/miniconda3/lib/R/bin/R
configure:2426: checking for endianness
configure:2435: result: little
configure:2446: checking for cat
configure:2469: found /usr/bin/cat
configure:2481: result: /usr/bin/cat
configure:2677: checking for C++ compiler version
configure:2686: x86_64-conda-linux-gnu-c++ -std=gnu++11 --version >&5
x86_64-conda-linux-gnu-c++ (conda-forge gcc 9.4.0-16) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:2697: $? = 0
configure:2686: x86_64-conda-linux-gnu-c++ -std=gnu++11 -v >&5
Reading specs from /public/home/maintain/miniconda3/bin/../lib/gcc/x86_64-conda-linux-gnu/9.4.0/specs
could not find specs file conda.specs
COLLECT_GCC=x86_64-conda-linux-gnu-c++
COLLECT_LTO_WRAPPER=/public/home/maintain/miniconda3/bin/../libexec/gcc/x86_64-conda-linux-gnu/9.4.0/lto-wrapper
Target: x86_64-conda-linux-gnu
Configured with: ../configure --prefix=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668900000/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho --with-slibdir=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668900000/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/lib --libdir=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668900000/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/lib --mandir=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668900000/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/man --build=x86_64-conda-linux-gnu --host=x86_64-conda-linux-gnu --target=x86_64-conda-linux-gnu --enable-default-pie --enable-languages=c,c++,fortran,objc,obj-c++ --enable-__cxa_atexit --disable-libmudflap --enable-libgomp --disable-libssp --enable-libquadmath --enable-libquadmath-support --enable-libsanitizer --enable-lto --enable-threads=posix --enable-target-optspace --enable-plugin --enable-gold --disable-nls --disable-bootstrap --disable-multilib --enable-long-long --with-sysroot=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668900000/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/x86_64-conda-linux-gnu/sysroot --with-build-sysroot=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668900000/_build_env/x86_64-conda-linux-gnu/sysroot --with-gxx-include-dir=/home/conda/feedstock_root/build_artifacts/gcc_compilers_1650668900000/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/x86_64-conda-linux-gnu/include/c++/9.4.0 --with-pkgversion='conda-forge gcc 9.4.0-16' --with-bugurl=https://github.com/conda-forge/ctng-compilers-feedstock/issues/new/choose
Thread model: posix
gcc version 9.4.0 (conda-forge gcc 9.4.0-16)
configure:2697: $? = 0
configure:2686: x86_64-conda-linux-gnu-c++ -std=gnu++11 -V >&5
x86_64-conda-linux-gnu-c++: error: unrecognized command line option '-V'
x86_64-conda-linux-gnu-c++: fatal error: no input files
compilation terminated.
configure:2697: $? = 1
configure:2686: x86_64-conda-linux-gnu-c++ -std=gnu++11 -qversion >&5
x86_64-conda-linux-gnu-c++: error: unrecognized command line option '-qversion'; did you mean '--version'?
x86_64-conda-linux-gnu-c++: fatal error: no input files
compilation terminated.
configure:2697: $? = 1
configure:2717: checking whether the C++ compiler works
configure:2739: x86_64-conda-linux-gnu-c++ -std=gnu++11 ...
collect2: error: ld returned 1 exit status
configure:2743: $? = 1
configure:2783: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "stringi"
| #define PACKAGE_TARNAME "stringi"
| #define PACKAGE_VERSION "1.8"
| #define PACKAGE_STRING "stringi 1.8"
| #define PACKAGE_BUGREPORT "https://stringi.gagolewski.com/"
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
|
| int
| main (void)
| {
|
|   ;
|   return 0;
| }
configure:2788: error: in `/tmp/Rtmpmip14o/downloaded_packages/stringi':
configure:2790: error: C++ compiler cannot create executables
See `config.log' for more details

I notice that there're error related with 'gcc -V' 'gcc -qversion',but I still don't know how to solve it.

What's more, the gcc compiler works fine when I do compilation manually. Here's my sessioninfo:

R version 4.0.5 (2021-03-31)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /public/home/maintain/miniconda3/lib/libopenblasp-r0.3.20.so

locale:
 [1] LC_CTYPE=zh_CN.UTF-8       LC_NUMERIC=C               LC_TIME=zh_CN.UTF-8       
 [4] LC_COLLATE=zh_CN.UTF-8     LC_MONETARY=zh_CN.UTF-8    LC_MESSAGES=zh_CN.UTF-8   
 [7] LC_PAPER=zh_CN.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=zh_CN.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RcppDist_0.1.1.9000

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.12         compiler_4.0.5      later_1.3.2         BiocManager_1.30.18
 [5] urlchecker_1.0.1    prettyunits_1.1.1   profvis_0.3.8       remotes_2.5.0      
 [9] tools_4.0.5         digest_0.6.35       pkgbuild_1.3.1      pkgload_1.3.4      
[13] memoise_2.0.1       lifecycle_1.0.4     rlang_1.1.3         shiny_1.7.1        
[17] cli_3.6.2           rstudioapi_0.13     curl_5.2.1          fastmap_1.1.1      
[21] withr_3.0.0         stringr_1.5.1       fs_1.6.3            htmlwidgets_1.6.4  
[25] vctrs_0.6.5         devtools_2.4.5      rprojroot_2.0.3     glue_1.7.0         
[29] R6_2.5.1            processx_3.8.3      sessioninfo_1.2.2   callr_3.7.5        
[33] purrr_1.0.2         magrittr_2.0.3      ps_1.7.6            promises_1.3.0     
[37] ellipsis_0.3.2      htmltools_0.5.8.1   usethis_2.1.6       mime_0.12          
[41] xtable_1.8-4        httpuv_1.6.15       stringi_1.7.6       miniUI_0.1.1.1     
[45] cachem_1.0.8        crayon_1.5.2 

My gcc version:gcc version 9.3.0 (GCC)


Solution

  • If you manage your R environment by anaconda, try conda install conda-forge::gcc_linux-64 before installing stringi.