R Packages Fail to Compile with gcc

后端 未结 2 1921
死守一世寂寞
死守一世寂寞 2020-12-11 13:37

I downloaded bioconductor and attempted to install a package (\"limma\") which installed successfully, however when I tried to update bioconductor I keep getting errors rela

2条回答
  •  孤城傲影
    2020-12-11 14:20

    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.

提交回复
热议问题