This article is originally published at https://blogs.oracle.com/r/compendium/rss
When installing R packages on Linux 6, a common issue is that the native GCC compiler is not sufficient for building
C++ 2011 standard code. In some cases, the R package developer will identify the C++11 requirement on the package's CRAN site or in the compilation log. Or, the build log may simply return errors indicating the C++11 support is not available:
cc1plus: error: unrecognized command line option "-std=c++11"
Devtoolset is a back-port of modern development tools for older Linux versions. It provides current versions of the GNU Compiler Collection, GNU Debugger, and other development, debugging, and performance monitoring tools. It will not conflict with the Operating System's native GCC compiler tools because the bits are installed to a non-default location, namely /opt/rh.
For example, when installing the open source R package ranger on Linux 6.9, the build fails with:
Error: ranger requires a real C++11 compiler, e.g., gcc >= 4.7 or Clang >= 3.0. You probably have to update your C++ compiler.
Linux 6.9 contains GCC 4.4-7 by default, which does not support C++11 code:
# gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)
Copyright (C) 2010 Free Software Foundation, Inc.
GCC 4.8.1 was the first feature-complete implementation of the 2011 C++ standard, previously known as C++0x.
To resolve this problem, first install the devtoolset on Oracle Linux 6.
1. As root, download the Oracle public yum Linux 6 repository:
# wget https://public-yum.oracle.com/public-yum-ol6.repo
2. Enable the repositories corresponding to your Operating System. For example, with Oracle Linux 6.9:
# cat /etc/oracle-release
Oracle Linux Server release 6.9
3. Enable the Linux 6.9 and software collections repositories by setting enabled to 1:
[ol6_u9_base]
name=Oracle Linux $releasever Update 9 installation media copy ($basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL6/9/base/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
[ol6_software_collections]
name=Software Collection Library release 3.0 packages for Oracle Linux 6 (x86_64)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL6/SoftwareCollections/x86_64/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
4. Next, install the devtoolset packages. For Oracle Linux 6, the current version is devtoolset-7:
# yum install devtoolset-7
Which will successfully complete with the output:
Installed:
devtoolset-7.x86_64 0:7.1-4.el6
Complete!
5. To use devtoolset-7, enable it by executing:
# source /opt/rh/devtoolset-7/enable
Now we have access to gcc 7.3.1, which supports C++11 code.
# gcc --version
gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
Copyright (C) 2017 Free Software Foundation, Inc.
6. The ranger packages compiles successfully.
R> install.packages("ranger")
..
..
* DONE (ranger)
Making 'packages.html' ... done
Note that while these instructions were developed for Linux 6, they will also work for Linux 7 whenever newer components in the GNU development tool chain are required.
Thanks for visiting r-craft.org
This article is originally published at https://blogs.oracle.com/r/compendium/rss
Please visit source website for post related comments.