R-stan compilation Error possibly related to c++14

rstan

#1

Hello, stan community!

Additional discussion on problem I am dealing with could be found there

I am trying to run classical r-stan example from this official tutorial. But I can’t because I get the following error message:

Ben Goodrich suggested to set Sys.setenv(USE_CXX14=1) and include the following lines to Makevars file:

CXX14=g++
CXX14FLAGS=-O3

But I still get the same error message. I also have been trying to install.packages(“https://win-builder.r-project.org/OdTz9MCBT96j/rstan_2.18.1.zip”, repos = NULL) but then I can’t run library(‘rsatn’) as I get:

Error: package or namespace load failed for ‘rstan’ in rbind(info, getNamespaceInfo(env, “S3methods”)):
number of columns of matrices must match (see arg 2)

Please help me to figure out this problem.

Will be very greatfull for help!


#2

When you get the error involving rbind(info, getNamespaceInfo(env, "S3methods")), can you post the output of traceback(). Also, when restarting R you have to make sure that there are no stanfit objects being autoloaded into your session via the .RData file in the startup directory.


#3

Is it working now?


#4

Traceback return the following


#5

If you do require(rstan) instead of library(rstan) does it give you anything different?


#6

It gives the same error message.

Загрузка требуемого пакета: rstan
Загрузка требуемого пакета: ggplot2
Загрузка требуемого пакета: StanHeaders
Error: package or namespace load failed for ‘rstan’ in rbind(info, getNamespaceInfo(env, “S3methods”)):
number of columns of matrices must match (see arg 2)
Warning message:
пакет ‘rstan’ был собран под R версии 3.6.0


#7

OK. Maybe do remove.packages("rstan"), restart R cleanly, do install.packages("rstan") but then put

CXX14 = g++ -std=c++1y
CXX14FLAGS = -O3 -Wno-unused-variable -Wno-unused-function

into your ~/.R/Makevars file before trying to compile any Stan models.


#8

Hello, Ben!

Sorry for nonresponding for so loing as I was extremely bussy.

I made these steps but then I get the following message:

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! C:/R/R-3.5.1/library/StanHeaders/libs/x64/StanHeaders.dll: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
In addition: Warning message:
In readLines(file, warn = TRUE) :
incomplete final line found on ‘D:\Р’РЁР­\3 РєСѓСЂСЃ\РЎРѕРЅСЏ\8schools.stan’


#9

If cat(strsplit(Sys.getenv(“PATH”), “;”)[[1]], sep = “\n”) shows anything pertaining to mingw_32 (which appears likely), then you need to remove it from your PATH using something like


#10

Thank you for detailed steps! I has been following them carefully. And I get 10. However, I still get the error when trying to build a model:

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! g++: not found
make: *** [file20246b3242fb.o] Error 127
In addition: Warning messages:
1: In readLines(file, warn = TRUE) :
incomplete final line found on ‘D:\Р’РЁР­\3 РєСѓСЂСЃ\РЎРѕРЅСЏ\8schools.stan’
2: In system(cmd, intern = !verbose) :
running command ‘C:/R/R-35~1.1/bin/x64/R CMD SHLIB file20246b3242fb.cpp 2> file20246b3242fb.cpp.err.txt’ had status 1

My path looks likeRtools


#11

You should uninstall Rtools 3.4 and then make sure your path has nothing pertaining to mingw_32 or mingw_64. Once you do that, you can also try

pkgbuild::has_build_tools(debug = TRUE)

#12

I made these steps and the commant returns TRUE. But the error reamins the same when I am building the model.


#13

I have totally reinstalled all R related stuff following new installation guide https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Windows

Now all works greate! Thank you very much for your exensive help!

P.S. While installing R-tools I made my path look exactly like tutorial ones removeing all other rows.