首页 > 解决方案 > 由于 cpp11 编译错误,R tidyr 包安装失败(扩展模式 x 不包含参数包)

问题描述

我有以下与 cp11 相关的错误。看起来 cp11 编译有错误,我不知道如何解决。

我试图做的是卸载软件包并重新安装它。

我在 RHEL 7 上,gcc 版本是 4.8.5

> install.packages("tidyverse")
Installing package into ‘/datascience/R/x86_64-redhat-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
also installing the dependency ‘tidyr’

trying URL 'https://cran.rstudio.com/src/contrib/tidyr_1.1.1.tar.gz'
Content type 'application/x-gzip' length 879411 bytes (858 KB)
==================================================
downloaded 858 KB

trying URL 'https://cran.rstudio.com/src/contrib/tidyverse_1.3.0.tar.gz'
Content type 'application/x-gzip' length 712837 bytes (696 KB)
==================================================
downloaded 696 KB

* installing *source* package ‘tidyr’ ...
** package ‘tidyr’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG  -I"/usr/lib64/R/library/cpp11/include" -I/usr/local/include  -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c cpp11.cpp -o cpp11.o
In file included from /usr/lib64/R/library/cpp11/include/cpp11/as.hpp:8:0,
                 from /usr/lib64/R/library/cpp11/include/cpp11.hpp:5,
                 from /usr/lib64/R/library/cpp11/include/cpp11/declarations.hpp:8,
                 from cpp11.cpp:4:
/usr/lib64/R/library/cpp11/include/cpp11/protect.hpp: In lambda function:
/usr/lib64/R/library/cpp11/include/cpp11/protect.hpp:185:52: error: parameter packs not expanded with ‘...’:
       return unwind_protect_sexp([&] { return ptr_(a...); });
                                                    ^
/usr/lib64/R/library/cpp11/include/cpp11/protect.hpp:185:52: note:         ‘a’
/usr/lib64/R/library/cpp11/include/cpp11/protect.hpp:185:53: error: expansion pattern ‘a’ contains no argument packs
       return unwind_protect_sexp([&] { return ptr_(a...); });
                                                     ^
make: *** [cpp11.o] Error 1
ERROR: compilation failed for package ‘tidyr’
* removing ‘/datascience/R/x86_64-redhat-linux-gnu-library/3.6/tidyr’
Warning in install.packages :
  installation of package ‘tidyr’ had non-zero exit status
ERROR: dependency ‘tidyr’ is not available for package ‘tidyverse’
* removing ‘/datascience/R/x86_64-redhat-linux-gnu-library/3.6/tidyverse’
Warning in install.packages :
  installation of package ‘tidyverse’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/Rtmp7JHlRI/downloaded_packages’

标签: c++rtidyversetidyr

解决方案


如@Maurits Evers 所述,较新版本的 gcc 将正确编译 tidyr。

#Enable the rhscl repository
yum-config-manager --enable rhel-server-rhscl-7-rpms

#Install devtooset-X
yum install devtoolset-X

#Open a shell with the required environment variables.
scl enable devtoolset-X bash

之后打开一个 R shell。如果在非交互式脚本中使用,请获取 scl enable 文件,该文件将在当前 shell 中设置环境变量,

 source /opt/rh/devtoolset-X/enable

推荐阅读