New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in model fit: C++14 standard requested but CXX14 is not defined #569
Comments
|
Can you post the whole ~/.R/Makevars file? It may be that it is not finding
it. What is `Sys.getenv("R_MAKEVARS_USER")`?
…On Mon, Oct 15, 2018 at 12:45 PM RichardIanBarnes ***@***.***> wrote:
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: -> .shlib_internal
Execution halted
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command 'C:/PROGRA1/R/R-351.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
#565 <#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...
$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
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#569>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADOrqr1TnE-bWhTxjdQ7gDorUc6F8_E6ks5ulLufgaJpZM4XcuVe>
.
|
|
Hi Thank you very much for replying so soon! The Sys.getenv("R_MAKEVARS_USER") returns an empty string so it looks like, as you said, it isn't able to find it. Makevars.txt |
|
Try it after changing ~/.R/Makevars to You may also want to add |
|
Hi I added those lines to the ~/.R/Makevars and it seems to have resolved this particular issue. Thank you very much for your help. In fact - much to my shame - I just realised that there was a section on RStan installation for Windows which sets out the contents of the Makevars file! I hadn't followed these steps when I originally installed RStan (I just went straight to Having resolved this though I encountered another error with StanHeaders which I thought I had seen in one of the open issues but can't find it at the moment. I will try to find it again and then post on there. |
|
I was also getting this error: and I had to modify my |
|
I'm having this issue, not locally but when I do a TravisCI build on my package that depends on rstan. Is there a recommended way to setup an rstan dependency to avoid this? Below is the output I get: |
|
Nevermind, after much digging I needed to add this to my travis config file: This was necessary even though I'm not packaging a compiled Stan model. |
|
I'm afraid I'm getting the same error message and can't resolve the issue.
in both of them, but no luck. I'm afraid I don't have a computer science background so I may not be looking in the right place, or doing the right thing. Any additional guidance would be much appreciated. |
|
Hi there - I need to rack my memory on this. Let me have a look later on and I'll try to figure out what I did to resolve it and get back to you. |
|
Sorry the doc's so confusing. We're certainly open to suggestions in improving it if you have any. It's really hard with all the platform-specific config that's shared across R applications. You want the top-level Makevars for R. On my mac, that's in I set the |
|
Sorry unfortunately I'm still not having any luck with this. I'm on Windows, I understand that the
but I still get the same error message when trying to run a stan model:
Stan was working ok on my computer until I upgraded RStudio and R to version I've also tried searching for a |
|
You have to create a new The script will show you where it needs to go and I think will just create it all for you if you run it. I'm re-opening this issue, as nobody's going to react to comments on a closed issue. |
|
Just do
install.packages("
https://win-builder.r-project.org/1vUk5Gxm9QqM/rstan_2.19.1.zip", repos =
NULL)
…On Tue, Jun 18, 2019 at 1:55 PM Bob Carpenter ***@***.***> wrote:
Reopened #569 <#569>.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#569?email_source=notifications&email_token=AAZ2XKSETAMPRVC7AV3AO7TP3EOP3A5CNFSM4F3S4VPKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOSBMPMWA#event-2421749336>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAZ2XKR2YCH43PHGQUJPGILP3EOP3ANCNFSM4F3S4VPA>
.
|
Unfortunately I receive the following error message:
|
|
The main problem now seems to be R not being able to 'find' Rtools. Every time I run:
it determines
Not sure what to try next!I should probably refer to the Rtools debug manual. |
|
OK I seem to solve the Rtools issue by setting:
as detailed here rstudio/rstudio#3563. I'm still having the Makevars issue even after running the 'Configuration of the C++ Toolchain' script.. I can see the Makevars.win document in the
I'm not sure what next to try. I'm tempted to try a complete reinstallation of R, Rstudio, Rtools and Rstan to see if that helps. |
There is a space at the beginning of the string (typo) in bgoodri's comment so just remove that. |
I feel stupid for having missed this. Thanks so much qdread, Bob and Ben everything now seems to be working. |
"Error in .shlib_internal(args) : C++14 standard requested but CXX14 is not defined * removing ‘/home/travis/R/Library/rstan’" by using solution: stan-dev/rstan#569 (comment)
"Error in .shlib_internal(args) : C++14 standard requested but CXX14 is not defined * removing ‘/home/travis/R/Library/rstan’" by using solution: stan-dev/rstan#569 (comment)
|
I understand that this issue was closed based on: |
|
That link isn't needed anymore. Just install rstan from CRAN.
…On Tue, Sep 24, 2019 at 10:55 PM dvillacresesz ***@***.***> wrote:
I understand that this issue was closed based on:
install.packages("
https://win-builder.r-project.org/1vUk5Gxm9QqM/rstan_2.19.1.zip", repos =
NULL)
But that link isn't available anymore:
https://win-builder.r-project.org/1vUk5Gxm9QqM <http://url>
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#569?email_source=notifications&email_token=AAZ2XKTG7PVNQGXRG74WVF3QLLHJXA5CNFSM4F3S4VPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7QNRUA#issuecomment-534829264>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAZ2XKQULFAF64IVYQX2GLLQLLHJXANCNFSM4F3S4VPA>
.
|
|
I am facing the same issue on Linux. Do you have a solution for Linux machines? |
|
If you don't have CXX14 defined on Linux, then most likely your version of
R is much too old.
…On Wed, Sep 25, 2019 at 10:06 AM Nikhil Gupta ***@***.***> wrote:
I am facing the same issue on Linux. Do you have a solution for Linux
machines?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#569?email_source=notifications&email_token=AAZ2XKUVHUTAB73MFRKVB6TQLNV6JA5CNFSM4F3S4VPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7SBBOY#issuecomment-535040187>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAZ2XKQPDKQD3MFFNONE5QLQLNV6JANCNFSM4F3S4VPA>
.
|
|
Thank you very much for your quick and accurate response @bgoodri . Actually my problem is when I try: Specifications:
I am only having troubles with this package. For example, I have tried everything and this issue is the best documented, it's possible to solve this here or should I open another issue? Also, @ngupta23 I have in this same machine Ubuntu, and I have no problem whatsoever with any package there (I have the same packages in both OS). I believe you should: |
|
I would just install the binary package, but if you are going to build
packages from source on Windows then you need the appropriate
configuration, which is given on the wiki
https://github.com/stan-dev/rstan/wiki/Installing-RStan-from-source-on-Windows#configuration
…On Wed, Sep 25, 2019 at 12:05 PM dvillacresesz ***@***.***> wrote:
Thank you very much for your quick and accurate response @bgoodri
<https://github.com/bgoodri> . Actually my problem is when I try:
install.packages("OpenMx")
I get:
Installing package into ‘~/R/win-library/3.6’
(as ‘lib’ is unspecified)
There is a binary version available but the source version is later:
binary source needs_compilation
OpenMx 2.13.2 2.14.11 TRUE
installing the source package ‘OpenMx’
trying URL 'https://cran.rstudio.com/src/contrib/OpenMx_2.14.11.tar.gz'
Content type 'application/x-gzip' length 3386317 bytes (3.2 MB)
downloaded 3.2 MB
* installing *source* package 'OpenMx' ...
** package 'OpenMx' successfully unpacked and MD5 sums checked
** using staged installation
**********************************************
WARNING: this package has a configure script
It probably needs manual configuration
**********************************************
** libs
Error in .shlib_internal(args) :
C++14 standard requested but CXX14 is not defined
* removing 'C:/Users/dvill/Documents/R/win-library/3.6/OpenMx'
Warning in install.packages :
installation of package ‘OpenMx’ had non-zero exit status
Specifications:
1. OS: Windows 10 home-64 bits-x64-based processor
2. R: x86_64-w64-mingw32; arch x86_64; os mingw32; system x86_64,
mingw32
3. Rtools: 3.5.0.4
I am only having troubles with this package. For example, curl was
installed using compilation perfectly.
I have tried everything and this issue is the best documented, it's
possible to solve this here or should I open another issue?
Also, @ngupta23 <https://github.com/ngupta23> I have in this same machine
Ubuntu, and I have no problem whatsoever with any package there (I have the
same packages in both OS). I believe you should:
sudo apt update
sudo apt upgrade
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#569?email_source=notifications&email_token=AAZ2XKVTM22HM7Z2VY4NS6LQLOD3FA5CNFSM4F3S4VPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7SOFCQ#issuecomment-535093898>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAZ2XKXMKBK6EDMP5QDA7BTQLOD3FANCNFSM4F3S4VPA>
.
|
|
`cat ~/.R/Makevars CXX14 = g++ |
This allowed me to install the |
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: -> .shlib_internal
Execution halted
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command 'C:/PROGRA
1/R/R-351.1/bin/x64/R CMD SHLIB file55c71d73e8e.cpp 2> file55c71d73e8e.cpp.err.txt' had status 1I've searched everywhere for possible solutions. I reviewed the following issue posted by yanys7
#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.
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...
$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
The text was updated successfully, but these errors were encountered: