ERROR: compilation failed for package ‘interp’

Hi, I couldn't get past this error when trying to install the package 'interp'. I've just installed the latest version of R (4.3.0). Any help would be greatly appreciated. Thanks!

g++ -std=gnu++11 -I"/opt/R/4.3.0/lib/R/include" -DNDEBUG -I'/opt/R/4.3.0/lib/R/library/Rcpp/include' -I'/opt/R/4.3.0/lib/R/library/RcppEigen/include' -I/usr/local/include -fpic -g -O2 -c convexHull.cpp -o convexHull.o
In file included from /usr/include/c++/4.8.2/algorithm:62:0,
from convexHull.cpp:31:
/usr/include/c++/4.8.2/bits/stl_algo.h: In instantiation of ‘_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Point2D*, std::vector >; _Tp = Point2D; _Compare = graham_scan(std::vector)::__lambda1]’:
/usr/include/c++/4.8.2/bits/stl_algo.h:2296:78: required from ‘_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Point2D*, std::vector >; _Compare = graham_scan(std::vector)::__lambda1]’
/usr/include/c++/4.8.2/bits/stl_algo.h:2337:62: required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Point2D*, std::vector >; _Size = long int; _Compare = graham_scan(std::vector)::__lambda1]’
/usr/include/c++/4.8.2/bits/stl_algo.h:5499:44: required from ‘void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<Point2D*, std::vector >; _Compare = graham_scan(std::vector)::__lambda1]’
convexHull.cpp:85:6: required from here
/usr/include/c++/4.8.2/bits/stl_algo.h:2263:35: error: no match for call to ‘(graham_scan(std::vector)::__lambda1) (Point2D&, const Point2D&)’
while (__comp(*__first, __pivot))
^
convexHull.cpp:72:47: note: candidate is:
std::sort(points.begin(), points.end(), [&](Point2D &left, Point2D &right) {
^
convexHull.cpp:72:78: note: graham_scan(std::vector)::__lambda1
std::sort(points.begin(), points.end(), [&](Point2D &left, Point2D &right) {
^
convexHull.cpp:72:78: note: no known conversion for argument 2 from ‘const Point2D’ to ‘Point2D&’
In file included from /usr/include/c++/4.8.2/algorithm:62:0,
from convexHull.cpp:31:
/usr/include/c++/4.8.2/bits/stl_algo.h:2266:34: error: no match for call to ‘(graham_scan(std::vector)::__lambda1) (const Point2D&, Point2D&)’
while (__comp(__pivot, *__last))
^
convexHull.cpp:72:47: note: candidate is:
std::sort(points.begin(), points.end(), [&](Point2D &left, Point2D &right) {
^
convexHull.cpp:72:78: note: graham_scan(std::vector)::__lambda1
std::sort(points.begin(), points.end(), [&](Point2D &left, Point2D &right) {
^
convexHull.cpp:72:78: note: no known conversion for argument 1 from ‘const Point2D’ to ‘Point2D&’
make: *** [convexHull.o] Error 1
ERROR: compilation failed for package ‘interp’

I'm afraid that you'll probably need a newer compiler. What is your OS?

Thanks! It’s CentOS 7. Which one should work best?

Update: I just updated my compiler to the latest version (g++ 11.2.1) and this fixed the issue.

This works for me: Replacing gcc with a newer version on CentOS 7 - CentOS

# Get repo that has devtoolset packages
$ sudo yum install centos-release-scl-rh

# Install necessary packages
$ sudo yum install devtoolset-8-toolchain

# Start bash that sees the devtoolset's version first
$ scl enable devtoolset-8 bash
# proof
$ which gcc
/opt/rh/devtoolset-8/root/usr/bin/gcc

# Compile your applications

# End bash session
$ exit
# proof
$ which gcc
/usr/bin/gcc

You should only need the new compiler while installing interp (and potentially other packages packages that also need a new compiler).

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.