c++ - 编译 rcpp 时遇到问题

标签 c++ linux r gcc centos

我在 CentOS 6.5 机器上安装 Rcpp for R 3.2.2 时遇到一些问题。我在 StackOverflow 和其他论坛上找到的答案都没有真正帮助,这些论坛似乎没有提供太多解决这个问题的方法。如果我尝试从 R 中或从命令行使用 R CMD INSTALL 安装,我最终会遇到类似的错误,即 Rcpp 无法安装并出现最终错误 make: *** [Date.o] 错误 1 之前的行/错误是 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../。 ./include/c++/4.4.7/exception:35: 错误:行尾前的预期声明

下面是我尝试通过 R CMD INSTALL Rcpp_0.12.1.tar.gzhttps://cran.rstudio.com/src/contrib/ 获取 tarball 后进行安装。 .

$ sudo R CMD INSTALL Rcpp_0.12.1.tar.gz
* installing to library ‘/usr/lib64/R/library’
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** libs
g++ -m64 -I/usr/include/R -DNDEBUG -I../inst/include/ -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic  -c Date.cpp -o Date.o
In file included from ../inst/include/Rcpp/platform/compiler.h:100,
                 from ../inst/include/Rcpp/r/headers.h:48,
                 from ../inst/include/RcppCommon.h:29,
                 from ../inst/include/Rcpp.h:27,
                 from Date.cpp:31:
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cmath:43:28: error: bits/c++config.h: No such file or directory
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_tree.h:63,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/map:60,
                 from ../inst/include/Rcpp/platform/compiler.h:176,
                 from ../inst/include/Rcpp/r/headers.h:48,
                 from ../inst/include/RcppCommon.h:29,
                 from ../inst/include/Rcpp.h:27,
                 from Date.cpp:31:
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/allocator.h:48:31: error: bits/c++allocator.h: No such file or directory
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ios:42,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:40,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iterator:65,
                 from ../inst/include/RcppCommon.h:49,
                 from ../inst/include/Rcpp.h:27,
                 from Date.cpp:31:
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/localefwd.h:42:76: error: bits/c++locale.h: No such file or directory
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/ios_base.h:41,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ios:43,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:40,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iterator:65,
                 from ../inst/include/RcppCommon.h:49,
                 from ../inst/include/Rcpp.h:27,
                 from Date.cpp:31:
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/atomicity.h:34:23: error: bits/gthr.h: No such file or directory
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/atomicity.h:35:30: error: bits/atomic_word.h: No such file or directory
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/basic_ios.h:39,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ios:45,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:40,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iterator:65,
                 from ../inst/include/RcppCommon.h:49,
                 from ../inst/include/Rcpp.h:27,
                 from Date.cpp:31:
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/locale_facets.h:43:30: error: bits/ctype_base.h: No such file or directory
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/locale_facets.h:1510:31: error: bits/ctype_inline.h: No such file or directory
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cmath:44,
                 from ../inst/include/Rcpp/platform/compiler.h:100,
                 from ../inst/include/Rcpp/r/headers.h:48,
                 from ../inst/include/RcppCommon.h:29,
                 from ../inst/include/Rcpp.h:27,
                 from Date.cpp:31:
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:69: error: expected constructor, destructor, or type conversion before ‘(’ token
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:74: error: ‘_GLIBCXX_END_NAMESPACE’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:87: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:110: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:125: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:145: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:152: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:159: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:166: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:198: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:205: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:212: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:219: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:226: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:233: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:240: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:247: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:265: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:272: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:279: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:296: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:310: error: ‘__gnu_cxx’ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:311: error: template argument 1 is invalid
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:355: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:378: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:385: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:392: error: ‘__true_type’ does not name a type
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h:417: error: ‘_GLIBCXX_END_NAMESPACE’ does not name a type
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cmath:45,
                 from ../inst/include/Rcpp/platform/compiler.h:100,
                 from ../inst/include/Rcpp/r/headers.h:48,
                 from ../inst/include/RcppCommon.h:29,
                 from ../inst/include/Rcpp.h:27,
                 from Date.cpp:31:
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/type_traits.h:45: error: ‘__enable_if’ is not a template
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/type_traits.h:64: error: ‘__is_integer’ is not a member of ‘std’
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/type_traits.h:64: error: ‘__is_integer’ is not a member of ‘std’
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/type_traits.h:64: error: template argument 1 is invalid
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/type_traits.h:64: error: typedef name may not be a nested-name-specifier
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/type_traits.h:64: error: expected ‘;’ before ‘>’ token
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/type_traits.h:67: error: ‘__if_type’ has not been declared
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/type_traits.h:107: error: ‘__is_integer’ is not a member of ‘std’
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/type_traits.h:107: error: ‘__is_integer’ is not a member of ‘std’
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/type_traits.h:107: error: template argument 1 is invalid
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/type_traits.h:107: error: typedef name may not be a nested-name-specifier
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/type_traits.h:107: error: expected ‘;’ before ‘>’ token
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/type_traits.h:110: error: ‘__if_type’ has not been declared
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/type_traits.h:158: error: ‘__is_integer’ is not a member of ‘std’
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/type_traits.h:158: error: expected primary-expression before ‘>’ token
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/type_traits.h:158: error: expected constructor, destructor, or type conversion before ‘>’ token
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/type_traits.h:163: error: ‘__promote’ is not a template
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cmath:46,
                 from ../inst/include/Rcpp/platform/compiler.h:100,
                 from ../inst/include/Rcpp/r/headers.h:48,
                 from ../inst/include/RcppCommon.h:29,
                 from ../inst/include/Rcpp.h:27,
                 from Date.cpp:31:
/usr/include/math.h:30: error: expected constructor, destructor, or type conversion before ‘extern’
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ios:40,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:40,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iterator:65,
                 from ../inst/include/RcppCommon.h:49,
                 from ../inst/include/Rcpp.h:27,
                 from Date.cpp:31:
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception:35: error: expected declaration before end of line
make: *** [Date.o] Error 1
ERROR: compilation failed for package ‘Rcpp’
* removing ‘/usr/lib64/R/library/Rcpp’

我尝试过的其他事情

  • 已验证 gcc.x86_64gcc-c++.x86_64gcc-gfortran.x86_64 已安装
  • 已验证 makeautomake 已安装

最佳答案

正如 comments above 中指出的那样诀窍是通过 SCL 使用新版本的编译器。

以下步骤改编自 Ask Xmodulo 上的此页面.

$ sudo wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo -P /etc/yum.repos.d
$ sudo sh -c 'echo "enabled=1" >> /etc/yum.repos.d/devtools-1.1.repo'

在 RHEL6 上,您可能需要更新已安装的 .repo 文件以手动将 baseurl 设置为 http://people.centos.org/tru/devtools-1.1/6/$basearch/RPMS。从那里:

$ sudo yum install devtoolset-1.1

要安装系统范围的 R 库,您需要以 root 身份运行它,所以执行 scl enable devtoolset-1.1 bash 然后运行 ​​sudo R 将运行应用程序但没有SCL 使能。所以改为:

$ sudo scl enable devtoolset-1.1 bash

这将在启用 SCL 的情况下以 root 身份启动 bash shell。最后你可以安装库:

# R CMD INSTALL Rcpp_0.12.1.tar.gz

关于c++ - 编译 rcpp 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33174490/

相关文章:

r - R Markdown 中带有 pdf_document 输出的表格和绘图之间的换行符

r - SparklyR 从 Spark 上下文中删除表

c++ - 如何在 Windows Mobile 6.x 上使用 Unicode 字体

c++ - 使用不同样本多次调用 OpenCV trainEM 函数

c++ - 在具有 'gdb' 的函数内的特定行中设置断点

c++ - Windows 上的 DLL Main 对比。 __attribute__((constructor)) Linux 上的入口点

.net - Hook 来自托管代码的 LoadLibrary 调用

linux - 完成意外标记附近的语法错误

linux - 在 Linux 中检测 IP 地址的更改

r - 如何删除部分 PerformanceAnalytics 图表?