Installation error

Hi,

I followed these steps to install rstan: RStan Getting Started · stan-dev/rstan Wiki · GitHub

Including these steps: Configuring C Toolchain for Windows · stan-dev/rstan Wiki · GitHub

Everything looked ok with no errors until I ran
install.packages(“rstan”, repos = “https://cloud.r-project.org/”, dependencies = TRUE)

and received this error:

* installing *source* package 'rstan' ...
** package 'rstan' successfully unpacked and MD5 sums checked
** libs

*** arch - i386
Error in .shlib_internal(args) : 
  C++14 standard requested but CXX14 is not defined

Can you advise what the issue is?

My makevars.win file looks like

CXX14FLAGS += -mtune=native -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2

I have r version 3.5.2 and Rtools version 3.5.0.4. I can install a package from source.

I also tried installing from cran and received the same errror.

Thank you

Any suggestions on this issue?

Can you try running:

cat("CXX14 = $(BINPREF)g++ -std=c++1y",
    file = "~/.R/Makevars.win", sep = "\n", append = TRUE)

Then restart R and try the install again?

After running that I received this warning message:

Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="NA": The system cannot find the file specified

But it did successfully install 2.21.2

Thank you!

I have a question (not sure if this is the right place to post but the topic seems related). After installing RStan I tried to verify my installation by running:

example(stan_model, package = “rstan”, run.dontrun = TRUE)

After doing so I then got this error message:

Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) :
C:/RBuildTools/4.0/mingw64/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: file6834192127b1.o:file6834192127b1.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D1Ev[_ZN3tbb8internal26task_scheduler_observer_v3D1Ev]+0x14): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:/RBuildTools/4.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: file6834192127b1.o:file6834192127b1.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D0Ev[_ZN3tbb8internal26task_scheduler_observer_v3D0Ev]+0x1c): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:/RBuildTools/4.0/mingw64/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: file6834192127b1.o:file6834192127b1.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD0Ev[_ZN3tbb10interface623task_scheduler_observerD0Ev]+0x1c): undefined reference to `tbb::internal::t

So I restarted R and reinstalled RStan and Stan headers by entering:

Sys.setenv(MAKEFLAGS = paste0("-j",parallel::detectCores()))

install.packages(c(“StanHeaders”,“rstan”),type=“source”)

However, I still get the same error message when I try to verify my RStan installation. What should I do?

I basically followed the steps outlined in: RStan Getting Started · stan-dev/rstan Wiki · GitHub

What version of R are you using?

I’m using R version 4.2.0 (2022-04-22 ucrt) – “Vigorous Calisthenics”

I’m having the same error as above, also using R version 4.2.0. Any resolution here?

Can you try using the preview of the next rstan version:

remove.packages(c("StanHeaders", "rstan"))
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
1 Like

That worked! Thanks for your help. For reference for others, my Makevars.win file looks like this:

CXX14FLAGS += -mtune=native -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2

CXX14 = $(BINPREF)g++ -std=c++1y

Also, using the following line can help you access your Makevars.win file:

usethis::edit_r_makevars()

I entered the code you sent through, then:

example(stan_model, package = “rstan”, run.dontrun = TRUE)

Now I get this error:

Error: unexpected input in “example(stan_model, package = “”

Any ideas?

The quotation marks get changed by discourse when they’re posted as text to the forum, you need to either change them or you can copy the code block below:

example(stan_model, package = "rstan", run.dontrun = TRUE)

My bad. Thank you, it is working now.