Mal
January 7, 2021, 7:52am
1
Trying to install the Package anomaly_4.0.0 on Red Hat Enterprise Linux Server release 7.2 (Maipo) using the command:
sudo R CMD INSTALL /home/.../anomaly_4.0.0.tar.gz
(R Version is 3.6.0 (2019-04-26) -- "Planting of a Tree")
I received the following error message: C++14 standard requested but CXX14 is not defined
After a little research I tried the solution provided here:
opened 04:45PM - 15 Oct 18 UTC
#### Summary:
Error message relating to C++compiler when running a linear model… fit.
#### Description:
I am new to Stan and RStan and trying out the tutorial by Max Farrell and Isla Myers-Smith on:
<https://ourcodingclub.github.io/2018/04/17/stan-intro.html>
The step by step process is shown below under 'Reproducible Steps'.
When I run the stanc() it compiles fine. But when I fit the linear model I receive the following error message:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! Error in .shlib_internal(commandArgs(TRUE)) :
C++14 standard requested but CXX14 is not defined
Calls: <Anonymous> -> .shlib_internal
Execution halted
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command 'C:/PROGRA~1/R/R-35~1.1/bin/x64/R CMD SHLIB file55c71d73e8e.cpp 2> file55c71d73e8e.cpp.err.txt' had status 1
I've searched everywhere for possible solutions. I reviewed the following issue posted by yanys7
<https://github.com/stan-dev/rstan/issues/565>
As suggested by bgoodri I created a ~/.R/Makevars file and inserted the following:
CXX14 = g++
However the problem still persists.
I don't know if this is a bug or if I'm doing something wrong.
Thanks in advance for any help you can provide.
#### Reproducible Steps:
This follows almost exactly the steps shown in the tutorial.
```
Sys.setenv(USE_CXX14 = 1)
library(rstan)
library(gdata)
library(bayesplot)
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())
seaice <- read.csv("seaice.csv", stringsAsFactors = F)
colnames(seaice)<-c("year", "extent_north", "extent_south")
x <- I(seaice$year - 1978)
y <- seaice$extent_north
N <- length(seaice$year)
stan_data <- list(N = N, x = x, y = y)
write("// Stan model for simple linear regression
data {
int <lower = 1> N;
vector[N] x;
vector[N] y;
}
parameters {
real alpha;
real beta;
real<lower = 0> sigma;
}
model {
y ~ normal(alpha + x * beta, sigma);
}
generated quantities {
},
"stan_model1.stan")
stanc("stan_model1.stan")
stan_model1 <- "stan_model1.stan"
fit <- stan(file = stan_model1, data = stan_data, warmup = 500, iter = 1000, chains = 4, thin = 1)
```
#### Current Output:
The output from ```stanc("stan_model1.stan")``` is below:
$`status`
[1] TRUE
$model_cppname
[1] "model55c23451a60_stan_model1"
$cppcode
[1] "// Code generated by Stan version 2.17.0\n\n#include <stan/model/model_header.hpp>\n\nnamespace model55c23451a60_stan_model1_namespace {\n\nusing std::istream;\nusing std::string;\nusing std::stringstream;\nusing std::vector;\nusing stan::io::dump;\nusing stan::math::lgamma;\nusing stan::model::prob_grad;\nusing namespace stan::math;\n\ntypedef Eigen::Matrix<double,Eigen::Dynamic,1> vector_d;\ntypedef Eigen::Matrix<double,1,Eigen::Dynamic> row_vector_d;\ntypedef Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> matrix_d;\n\nstatic int current_statement_begin__;\n\nstan::io::program_reader prog_reader__() {\n stan::io::program_reader reader;\n reader.add_event(0, 0, \"start\", \"model55c23451a60_stan_model1\");\n reader.add_event(19, 19, \"end\", \"model55c23451a60_stan_model1\");\n return reader;\n}\n\nclass model55c23451a60_stan_model1 : public prob_grad {\nprivate:\n int N;\n vector_d x;\n vector_d y;\npublic:\n model55c23451a60_stan_model1(stan::io::va... <truncated>
$model_name
[1] "stan_model1"
$model_code
[1] "// Stan model for simple linear regression\ndata {\n int <lower = 1> N; // Sample size\n vector[N] x; //Predictor\n vector[N] y; // Outcome\n}\n\nparameters {\n real alpha; //Intercept\n real beta; // Slope\n real<lower = 0> sigma; //Error SD\n}\n\nmodel {\n y ~ normal(alpha + x * beta, sigma);\n}\n\ngenerated quantities {\n} // The posterior predictive distribution"
attr(,"model_name2")
[1] "stan_model1"
#### Expected Output:
If applicable, the output you expected from RStan.
#### RStan Version:
RStan version 2.17.3
#### R Version:
R Version 3.5.1
#### Operating System:
Windows 8 64bit
After creating the Makevars file as described I run into the following error:
marshalling.cpp:192:90: Fehler: Parameter als »auto« deklariert
transform(cpts.begin(),cpts.end(),xstar.begin(),marshalled_result.begin(),[](auto& cpt,auto& x)
^
marshalling.cpp:192:100: Fehler: Parameter als »auto« deklariert
transform(cpts.begin(),cpts.end(),xstar.begin(),marshalled_result.begin(),[](auto& cpt,auto& x)
^
marshalling.cpp: In Lambda-Funktion:
marshalling.cpp:195:36: Fehler: »cpt« wurde in diesem Gültigkeitsbereich nicht definiert
entry[0] = (double)std::get<0>(cpt);
^
marshalling.cpp:197:16: Fehler: »x« wurde in diesem Gültigkeitsbereich nicht definiert
entry[2] = x;
^
I can’t find a solution to solve this error. Did anyone knows how to crack this? I am grateful for any advice.
There are a couple of proposed Makevars
files in that github thread--could you post the content of yours?
greg
January 8, 2021, 11:09pm
3
I looked into a similar issue with another package recently. I think the default C++ compiler on RHEL 7 (GCC 4.8.5) is just too old to build the anomaly package. GCC 4.8.5 does have partial support for C++14 using the -std=c++1y
flag (as mentioned in that rstan GitHub issue), but it's still not complete enough for anomaly.
To work around this, you could install the Red Hat Developer Toolset on your system to get a newer compiler: https://www.softwarecollections.org/en/scls/rhscl/devtoolset-8/
Or install the binary package for anomaly from the RStudio Public Package Manager server: https://packagemanager.rstudio.com/client/#/repos/2/overview
> options(repos = "https://packagemanager.rstudio.com/cran/__linux__/centos7/latest")
> install.packages("anomaly")
...
* installing *binary* package ‘anomaly’ ...
* DONE (anomaly)
Making 'packages.html' ... done
These binaries are precompiled with the Red Hat Developer Toolset, and should be compatible with a default RHEL 7 system.
If you go with the Red Hat Developer Toolset, there are a few more details in this thread, like how to activate it or how to install it on AWS: Reinstalling odbc on R 4.0 on Linux RHEL 7 .
If you go with the RStudio Package Manager binaries, you may also need additional configuration steps if you've installed R from EPEL: https://docs.rstudio.com/rspm/admin/serving-binaries/#binaries-r-configuration-linux
1 Like
Mal
January 11, 2021, 6:07am
4
Hey, here You have it:
CXX14 = g++ -std=c++1y -Wno-unused-variable -Wno-unused-function -fPIC
CXX14FLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -Wno-macro-redefined
CXX14=g++ -std=c++1y -fPIC
system
Closed
February 1, 2021, 6:07am
5
This topic was automatically closed 21 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.