在 CentOS-6.5 下使用源码安装的 R-3.6.0 在安装包的时候出现 “C++11 standard requested but CXX11 is not defined” 错误。下面是参考的解决方法。

    1. > install.packages("pillar")
    2. also installing the dependencies digest’, vctrs
    3. trying URL 'http://mirror.lzu.edu.cn/CRAN/src/contrib/digest_0.6.19.tar.gz'
    4. Content type 'application/octet-stream' length 140243 bytes (136 KB)
    5. ==================================================
    6. downloaded 136 KB
    7. ......
    8. * installing *source* package digest ...
    9. ** package digest successfully unpacked and MD5 sums checked
    10. ** using staged installation
    11. ** libs
    12. Error in .shlib_internal(args) :
    13. C++11 standard requested but CXX11 is not defined
    14. * removing ‘/RiboBio/Bioinfo/Pipeline/SoftWare/R/R-3.6.0/lib64/R/library/digest
    15. ERROR: dependency digest is not available for package vctrs
    16. * removing ‘/RiboBio/Bioinfo/Pipeline/SoftWare/R/R-3.6.0/lib64/R/library/vctrs
    17. ERROR: dependency vctrs is not available for package pillar
    18. * removing ‘/RiboBio/Bioinfo/Pipeline/SoftWare/R/R-3.6.0/lib64/R/library/pillar
    19. The downloaded source packages are in
    20. ‘/tmp/RtmpcowP8e/downloaded_packages
    21. Updating HTML index of packages in '.Library'
    22. Making 'packages.html' ... done
    23. Warning messages:
    24. 1: In install.packages("pillar") :
    25. installation of package digest had non-zero exit status
    26. 2: In install.packages("pillar") :
    27. installation of package vctrs had non-zero exit status
    28. 3: In install.packages("pillar") :
    29. installation of package pillar had non-zero exit status
    30. >

    解决方法:《“CXX11 is not defined” problem in MRO 3.4

    (Actually I vaguely remember encountering the same problem in MRO 3.3, and solved it using similar method. Unfortunately I didn’t write it down.)

    Note: MRO means Microsoft R Open (previously Revolution R) Recently I tried to set up the R development environment on a fresh Linux system, every thing went well until I hit this error installing xgboost: Package installation error: “C++11 standard requested but CXX11 is not defined”**After some Googling I found > this Github issue. It appears to be a MRO-specific problem, and > mjmg provided a working solution.> The gist is, replacing every “CXX1X” with “CXX11” in R compiler configuration files (System wide: ${R_HOME}/etc/Makeconf Per-user: ~/.R/Makevars) and fill in some values:

    1. CXX11 = g++
    2. CXX11FLAGS = -O2 -g $(LTO)
    3. CXX11PICFLAGS = -fPIC
    4. CXX11STD = -std=c++11

    That’s it!

    我个人的解决方法是,直接修改 /Bioinfo/Pipeline/SoftWare/R/R-3.6.0/lib64/R/etc/Makeconf 文件,替换下面的内容:

    1. CXX11 = g++
    2. CXX11FLAGS = -O2 -g $(LTO)
    3. CXX11PICFLAGS = -fPIC
    4. CXX11STD =
    • CXX11STD 值必须为空,否则在 R 中 install.packages() 会出现另外的错误:cc1plus: error: unrecognized command line option “-std=c++11”。