简体   繁体   中英

Trouble Compiling Rcpp

I'm having some trouble installing Rcpp for R 3.2.2 on a CentOS 6.5 box. I've found answers that didn't really help both here on StackOverflow and other forums that don't seem to offer much in terms of a solution to this problem. If I attempt to install from within R or from command line with R CMD INSTALL I'm greeted by similar errors ultimately that Rcpp couldn't be installed with the final error make: *** [Date.o] Error 1 and the line/error previous to that being /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception:35: error: expected declaration before end of line .

Below is my attempt at installing via R CMD INSTALL Rcpp_0.12.1.tar.gz after grabbing the tarball from https://cran.rstudio.com/src/contrib/ .

$ 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’

Other Things I've Tried

  • Verified that gcc.x86_64 , gcc-c++.x86_64 , and gcc-gfortran.x86_64 are installed
  • Verified that make and automake are installed

As pointed out in the comments above the trick was using a new version of the compiler via an SCL.

The steps below are adapted from this page on 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'

On RHEL6 ayou may need to update the .repo file that got installed to manually set the baseurl to http://people.centos.org/tru/devtools-1.1/6/$basearch/RPMS . From there:

$ sudo yum install devtoolset-1.1

To install system wide R libraries you need to run it as root so doing scl enable devtoolset-1.1 bash and then running sudo R will run the application but without the SCL enabled. So instead:

$ sudo scl enable devtoolset-1.1 bash

That will start a bash shell as root with the SCL enabled. Finally you can install the library with:

# R CMD INSTALL Rcpp_0.12.1.tar.gz

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM