R Packages Fail to Compile with gcc

本小妞迷上赌 提交于 2020-01-19 17:39:35

问题


I downloaded bioconductor and attempted to install a package ("limma") which installed successfully, however when I tried to update bioconductor I keep getting errors relating to invalid compiler options. It seems to be specific to gcc, the gfortran packages install without issue.

Here is the output:

[xxx]$ su -c 'R'
Password: 

R version 2.15.2 (2012-10-26) -- "Trick or Treat"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-redhat-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> source("http://bioconductor.org/biocLite.R")
Bioconductor version 2.11 (BiocInstaller 1.8.3), ?biocLite for help
> biocLite("BiocUpgrade")
BioC_mirror: http://bioconductor.org
Using Bioconductor version 2.11 (BiocInstaller 1.8.3), R version 2.15.
Old packages: 'Biobase', 'foreign', 'IRanges', 'lattice', 'MASS', 'Matrix',
  'mvtnorm', 'nlme', 'rpart', 'survival', 'waveslim', 'wavethresh'
Update all/some/none? [a/s/n]: a
trying URL 'http://bioconductor.org/packages/2.11/bioc/src/contrib/Biobase_2.18.0.tar.gz'
Content type 'application/x-gzip' length 1913386 bytes (1.8 Mb)
opened URL
==================================================
downloaded 1.8 Mb

trying URL 'http://cran.fhcrc.org/src/contrib/foreign_0.8-52.tar.gz'
Content type 'application/x-gzip' length 318387 bytes (310 Kb)
opened URL
==================================================
downloaded 310 Kb

trying URL 'http://bioconductor.org/packages/2.11/bioc/src/contrib/IRanges_1.16.5.tar.gz'
Content type 'application/x-gzip' length 699291 bytes (682 Kb)
opened URL
==================================================
downloaded 682 Kb

trying URL 'http://cran.fhcrc.org/src/contrib/lattice_0.20-13.tar.gz'
Content type 'application/x-gzip' length 367715 bytes (359 Kb)
opened URL
==================================================
downloaded 359 Kb

trying URL 'http://cran.fhcrc.org/src/contrib/MASS_7.3-23.tar.gz'
Content type 'application/x-gzip' length 472005 bytes (460 Kb)
opened URL
==================================================
downloaded 460 Kb

trying URL 'http://cran.fhcrc.org/src/contrib/Matrix_1.0-11.tar.gz'
Content type 'application/x-gzip' length 1676392 bytes (1.6 Mb)
opened URL
==================================================
downloaded 1.6 Mb

trying URL 'http://cran.fhcrc.org/src/contrib/mvtnorm_0.9-9994.tar.gz'
Content type 'application/x-gzip' length 322279 bytes (314 Kb)
opened URL
==================================================
downloaded 314 Kb

trying URL 'http://cran.fhcrc.org/src/contrib/nlme_3.1-108.tar.gz'
Content type 'application/x-gzip' length 694594 bytes (678 Kb)
opened URL
==================================================
downloaded 678 Kb

trying URL 'http://cran.fhcrc.org/src/contrib/rpart_4.1-0.tar.gz'
Content type 'application/x-gzip' length 808365 bytes (789 Kb)
opened URL
==================================================
downloaded 789 Kb

trying URL 'http://cran.fhcrc.org/src/contrib/survival_2.37-2.tar.gz'
Content type 'application/x-gzip' length 1714302 bytes (1.6 Mb)
opened URL
==================================================
downloaded 1.6 Mb

trying URL 'http://cran.fhcrc.org/src/contrib/waveslim_1.7.1.tar.gz'
Content type 'application/x-gzip' length 703759 bytes (687 Kb)
opened URL
==================================================
downloaded 687 Kb

trying URL 'http://cran.fhcrc.org/src/contrib/wavethresh_4.6.1.tar.gz'
Content type 'application/x-gzip' length 525390 bytes (513 Kb)
opened URL
==================================================
downloaded 513 Kb

* installing *source* package ‘Biobase’ ...
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG  -I/usr/local/include    -fpic  -O2 -g -pipe     -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4      -m64 -mtune=generic  -c Rinit.c -o Rinit.o
cc1: error: unrecognized command line option "-fstack-protector"
cc1: error: invalid parameter `ssp-buffer-size'
Rinit.c:1: error: bad value (generic) for -mtune= switch
make: *** [Rinit.o] Error 1
ERROR: compilation failed for package ‘Biobase’
* removing ‘/usr/lib64/R/library/Biobase’
* restoring previous ‘/usr/lib64/R/library/Biobase’
* installing *source* package ‘foreign’ ...
** package ‘foreign’ successfully unpacked and MD5 sums checked
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG  -I/usr/local/include    -fpic  -O2 -g -pipe     -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4      -m64 -mtune=generic  -c R_systat.c -o R_systat.o
cc1: error: unrecognized command line option "-fstack-protector"
cc1: error: invalid parameter `ssp-buffer-size'
R_systat.c:1: error: bad value (generic) for -mtune= switch
make: *** [R_systat.o] Error 1
ERROR: compilation failed for package ‘foreign’
* removing ‘/usr/lib64/R/library/foreign’
* restoring previous ‘/usr/lib64/R/library/foreign’
* installing *source* package ‘IRanges’ ...
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG  -I/usr/local/include    -fpic  -O2 -g -pipe     -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4      -m64 -mtune=generic  -c AEbufs.c -o AEbufs.o
cc1: error: unrecognized command line option "-fstack-protector"
cc1: error: invalid parameter `ssp-buffer-size'
AEbufs.c:1: error: bad value (generic) for -mtune= switch
make: *** [AEbufs.o] Error 1
ERROR: compilation failed for package ‘IRanges’
* removing ‘/usr/lib64/R/library/IRanges’
* restoring previous ‘/usr/lib64/R/library/IRanges’
* installing *source* package ‘lattice’ ...
** package ‘lattice’ successfully unpacked and MD5 sums checked
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG  -I/usr/local/include    -fpic  -O2 -g -pipe     -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4      -m64 -mtune=generic  -c init.c -o init.o
cc1: error: unrecognized command line option "-fstack-protector"
cc1: error: invalid parameter `ssp-buffer-size'
init.c:1: error: bad value (generic) for -mtune= switch
make: *** [init.o] Error 1
ERROR: compilation failed for package ‘lattice’
* removing ‘/usr/lib64/R/library/lattice’
* restoring previous ‘/usr/lib64/R/library/lattice’
* installing *source* package ‘MASS’ ...
** package ‘MASS’ successfully unpacked and MD5 sums checked
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG  -I/usr/local/include    -fpic  -O2 -g -pipe     -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4      -m64 -mtune=generic  -c MASS.c -o MASS.o
cc1: error: unrecognized command line option "-fstack-protector"
cc1: error: invalid parameter `ssp-buffer-size'
MASS.c:1: error: bad value (generic) for -mtune= switch
make: *** [MASS.o] Error 1
ERROR: compilation failed for package ‘MASS’
* removing ‘/usr/lib64/R/library/MASS’
* restoring previous ‘/usr/lib64/R/library/MASS’
* installing *source* package ‘mvtnorm’ ...
** package ‘mvtnorm’ successfully unpacked and MD5 sums checked
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG  -I/usr/local/include    -fpic  -O2 -g -pipe     -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4      -m64 -mtune=generic  -c miwa.c -o miwa.o
cc1: error: unrecognized command line option "-fstack-protector"
cc1: error: invalid parameter `ssp-buffer-size'
miwa.c:1: error: bad value (generic) for -mtune= switch
make: *** [miwa.o] Error 1
ERROR: compilation failed for package ‘mvtnorm’
* removing ‘/usr/lib64/R/library/mvtnorm’
* restoring previous ‘/usr/lib64/R/library/mvtnorm’
* installing *source* package ‘rpart’ ...
** package ‘rpart’ successfully unpacked and MD5 sums checked
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG  -I/usr/local/include    -fpic  -O2 -g -pipe     -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4      -m64 -mtune=generic  -c anova.c -o anova.o
cc1: error: unrecognized command line option "-fstack-protector"
cc1: error: invalid parameter `ssp-buffer-size'
anova.c:1: error: bad value (generic) for -mtune= switch
make: *** [anova.o] Error 1
ERROR: compilation failed for package ‘rpart’
* removing ‘/usr/lib64/R/library/rpart’
* restoring previous ‘/usr/lib64/R/library/rpart’
* installing *source* package ‘survival’ ...
** package ‘survival’ successfully unpacked and MD5 sums checked
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG  -I/usr/local/include    -fpic  -O2 -g -pipe     -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4      -m64 -mtune=generic  -c agexact.c -o agexact.o
cc1: error: unrecognized command line option "-fstack-protector"
cc1: error: invalid parameter `ssp-buffer-size'
agexact.c:1: error: bad value (generic) for -mtune= switch
make: *** [agexact.o] Error 1
ERROR: compilation failed for package ‘survival’
* removing ‘/usr/lib64/R/library/survival’
* restoring previous ‘/usr/lib64/R/library/survival’
* installing *source* package ‘waveslim’ ...
** package ‘waveslim’ successfully unpacked and MD5 sums checked
** libs
gfortran -m64   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-    protector --param=ssp-buffer-size=4  -m64 -mtune=generic -I/usr/lib64/gfortran/modules  -c     bell-p-w.f -o bell-p-w.o
bell-p-w.f:131.15:

         MAXIT=(K+3)*ROOTN                                              
               1
Warning: Possible change of value in conversion from REAL(8) to INTEGER(4) at (1)
bell-p-w.f:344.18:

      INTEGER N, I, L, K, IFAULT                                        
                  1
Warning: Unused variable 'i' declared at (1)
bell-p-w.f:345.36:

      DOUBLE PRECISION V(N), RN, STD, DSUM, DWSUM, ZERO, ONE,           
                                    1
Warning: Unused variable 'std' declared at (1)
bell-p-w.f:346.18:

     * TWO, ZFLOAT                                                      
                  1
Warning: Unused variable 'zfloat' declared at (1)
bell-p-w.f: In function ‘dpss’:
bell-p-w.f:203:0: warning: ‘sum’ may be used uninitialized in this function [-Wmaybe-    uninitialized]
bell-p-w.f:207:0: warning: ‘ssnorm’ may be used uninitialized in this function [-Wmaybe-    uninitialized]
bell-p-w.f:203:0: warning: ‘diff’ may be used uninitialized in this function     [-Wmaybe-    uninitialized]
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG  -I/usr/local/include    -fpic  -O2 -g -pipe     -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4      -m64 -mtune=generic  -c dwt.c -o dwt.o
cc1: error: unrecognized command line option "-fstack-protector"
cc1: error: invalid parameter `ssp-buffer-size'
dwt.c:1: error: bad value (generic) for -mtune= switch
make: *** [dwt.o] Error 1
ERROR: compilation failed for package ‘waveslim’
* removing ‘/usr/lib64/R/library/waveslim’
* restoring previous ‘/usr/lib64/R/library/waveslim’
* installing *source* package ‘Matrix’ ...
** package ‘Matrix’ successfully unpacked and MD5 sums checked
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -DNTIMER -I./SuiteSparse_config -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-    protector --param=ssp-buffer-size=4  -m64 -mtune=generic  -c CHMfactor.c -o CHMfactor.o
cc1: error: unrecognized command line option "-fstack-protector"
cc1: error: invalid parameter `ssp-buffer-size'
CHMfactor.c:1: error: bad value (generic) for -mtune= switch
make: *** [CHMfactor.o] Error 1
ERROR: compilation failed for package ‘Matrix’
* removing ‘/usr/lib64/R/library/Matrix’
* restoring previous ‘/usr/lib64/R/library/Matrix’
* installing *source* package ‘nlme’ ...
** package ‘nlme’ successfully unpacked and MD5 sums checked
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG  -I/usr/local/include   -fvisibility=hidden -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector     --param=ssp-buffer-size=4  -m64 -mtune=generic  -c corStruct.c -o corStruct.o
cc1: error: unrecognized command line option "-fstack-protector"
cc1: error: invalid parameter `ssp-buffer-size'
corStruct.c:1: error: bad value (generic) for -mtune= switch
make: *** [corStruct.o] Error 1
ERROR: compilation failed for package ‘nlme’
* removing ‘/usr/lib64/R/library/nlme’
* restoring previous ‘/usr/lib64/R/library/nlme’
* installing *source* package ‘wavethresh’ ...
** package ‘wavethresh’ successfully unpacked and MD5 sums checked
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG  -I/usr/local/include    -fpic  -O2 -g -pipe     -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4      -m64 -mtune=generic  -c WAVDE.c -o WAVDE.o
cc1: error: unrecognized command line option "-fstack-protector"
cc1: error: invalid parameter `ssp-buffer-size'
WAVDE.c:1: error: bad value (generic) for -mtune= switch
make: *** [WAVDE.o] Error 1
ERROR: compilation failed for package ‘wavethresh’
* removing ‘/usr/lib64/R/library/wavethresh’
* restoring previous ‘/usr/lib64/R/library/wavethresh’

The downloaded source packages are in
        ‘/tmp/RtmpKXUsRY/downloaded_packages’
Updating HTML index of packages in '.Library'

Making packages.html  ... done
There were 13 warnings (use warnings() to see them)

I am running: Linux fedora 3.6.8-2.fc17.x86_64 gcc-4.7.2-2.fc17.x86_64 R 2.15.2 However all I see in /usr/bin is gcc34, so I'm not exactly sure. I have to start R with sudo because for all but the package data.tables, it doesn't have access to install in the directories.


回答1:


Modify your PATH to make sure that a gcc compiler more recent than gcc 3.2 is found.

If necessary, create a link to the recent one (assuming you want to still keep gcc 3.2 around):

mkdir $HOME/bin
ln -s /usr/bin/gcc-VERSION $HOME/bin/gcc
export PATH=$HOME/bin:$PATH
# proceed to your normal installation

VERSION indicates the gcc version of the compiler normally used in your system




回答2:


I had a similar problem trying to install mvtnorm in R on Ubuntu. I was getting the error:

gcc: error: unrecognized command line option "-fstack-protector-strong"

I looked into which version of gcc was being used by default

which gcc
/home/ralien/anaconda3/bin/gcc

It turns out that, for some reason, Anaconda uses a gcc, g++, and gfortran compiler that is really old: version 4.8.5. This version doesn't seem to support the -fstack-protector-strong argument.

I checked the gcc, g++, and gfortran version in /usr/bin and saw that my system compilers were much newer, 5.4 or so. The trick is to force R to use the new compilers by creating

~/.R/Makevars

and changing the path for ALL compilers to the system version. So the Makevars file would contain the entries:

CC=/usr/bin/gcc
CXX=/usr/bin/g++
FC=/usr/bin/gfortran
F77=/usr/bin/gfortran

You can then use R CMD INSTALL to compile the package with the new version of gcc, g++, and gfortran.

Or at least this worked for me.



来源:https://stackoverflow.com/questions/14865976/r-packages-fail-to-compile-with-gcc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!