在 CentOS-6.5 下使用源码安装的 R-3.6.0 在安装包的时候出现 “C++11 standard requested but CXX11 is not defined” 错误。下面是参考的解决方法。
> install.packages("pillar")
also installing the dependencies ‘digest’, ‘vctrs’
trying URL 'http://mirror.lzu.edu.cn/CRAN/src/contrib/digest_0.6.19.tar.gz'
Content type 'application/octet-stream' length 140243 bytes (136 KB)
==================================================
downloaded 136 KB
......
* installing *source* package ‘digest’ ...
** package ‘digest’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
Error in .shlib_internal(args) :
C++11 standard requested but CXX11 is not defined
* removing ‘/RiboBio/Bioinfo/Pipeline/SoftWare/R/R-3.6.0/lib64/R/library/digest’
ERROR: dependency ‘digest’ is not available for package ‘vctrs’
* removing ‘/RiboBio/Bioinfo/Pipeline/SoftWare/R/R-3.6.0/lib64/R/library/vctrs’
ERROR: dependency ‘vctrs’ is not available for package ‘pillar’
* removing ‘/RiboBio/Bioinfo/Pipeline/SoftWare/R/R-3.6.0/lib64/R/library/pillar’
The downloaded source packages are in
‘/tmp/RtmpcowP8e/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning messages:
1: In install.packages("pillar") :
installation of package ‘digest’ had non-zero exit status
2: In install.packages("pillar") :
installation of package ‘vctrs’ had non-zero exit status
3: In install.packages("pillar") :
installation of package ‘pillar’ had non-zero exit status
>
解决方法:《“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:
CXX11 = g++
CXX11FLAGS = -O2 -g $(LTO)
CXX11PICFLAGS = -fPIC
CXX11STD = -std=c++11
That’s it!
我个人的解决方法是,直接修改 /Bioinfo/Pipeline/SoftWare/R/R-3.6.0/lib64/R/etc/Makeconf 文件,替换下面的内容:
CXX11 = g++
CXX11FLAGS = -O2 -g $(LTO)
CXX11PICFLAGS = -fPIC
CXX11STD =
- CXX11STD 值必须为空,否则在 R 中 install.packages() 会出现另外的错误:cc1plus: error: unrecognized command line option “-std=c++11”。