I'm working on a linux box, with the Makevars file I created in ~/.R/Makevars containing the following:
CXX = g++
CXXSTD = -std=gnu++17
I am running R 3.5.1-intel-mkl with the following code:
library(Rcpp)
library(RcppArmadillo)
sourceCpp("code.cpp",cacheDir="~/goldfish/solvers/junkdir",rebuild=T,showOutput=T,verbose=T)
I doubt the contents of the cpp file is important as the error is referring to environmental issues:
code.cpp: In function ‘void polyRegression(const std::vector<int, std::allocator<int> >&, const std::vector<int, std::allocator<int> >&)’:
code.cpp:188:18: error: ‘transform_reduce’ is not a member of ‘std’
I tried this line of code (thanks to this answer)
g++ -x c++ -E -dM -< /dev/null | grep __cplusplus
to test for the version and this was the output:
#define __cplusplus 201402L
Which according to this answer may mean partial support. I'm a bit lost, so my questions are:
1) Is the transform_reduce method not supported in this version of g++? If not, can you recommend any alternatives? 2) If transform_reduce IS supported and I have an error in my Makevars, or the OS isn't picking it up for some reason, how do I force the OS to find it?
EDIT:
Following advice from Dirk Eddelbuettel (thanks again) I need to set all the correct variables and flags in the Makevars. I've read through this answer, too, which was enlightening, but I'm unsure what to set for C++ to compile to a version for transform_reduce to function. Here are my flags at the moment (I thought CXXSTD
and CXX17STD
would solve the issue, but it hasn't).
CXX = g++
CXXSTD = -std=gnu++17
CXXCPP = $(CXX) -E
CXXFLAGS = -g -O2 $(LTO)
CXXPICFLAGS = -fpic
CXX98 = g++
CXX98FLAGS = -g -O2
CXX98PICFLAGS = -fpic
CXX98STD = -std=gnu++98
CXX11 = g++
CXX11FLAGS = -g -O2
CXX11PICFLAGS = -fpic
CXX11STD = -std=gnu++11
CXX14 = g++
CXX14FLAGS = -g -O2
CXX14PICFLAGS = -fpic
CXX14STD = -std=gnu++14
CXX17 = g++
CXX17FLAGS = -g -O2
CXX17PICFLAGS = -fpic
CXX17STD = -std=gnu++17