R Packages Fail to Compile with gcc

后端 未结 2 1916
死守一世寂寞
死守一世寂寞 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:18

    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

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题