C++14 standard requested but CXX14 is not defined (again, with rstantools 2.0.0)

I tried to port package dmenne/breathteststan (github, CRAN) to use the stucture of rstantools 2.0.0. Works fine in my local Windows build, but gives the well known C++14 standard requested but CXX14 is not defined on r-hub (https://builder.r-hub.io/status/breathteststan_0.4.7.9000.tar.gz-be031122f1124ebc8ae7c363a5f2d0ca). r-hub Mac build is fine.

Since makevars.xxx is now generated by rstanstools, I don’t want to change it using one of the old methods. Any suggestion?

It appears that R-hub does not define CXX14 like winbuilder does. But in my experience, R-hub should be fine for testing of any non-Windows configuration.

Unrelated to your problem, but since I had a look at your repository, it seems to me that you can avoid having the *.h files and the RcppExports.cpp in the repository, as they are automatically generated by rstantools::rstan_config().

1 Like

Thanks, you are right. I kept these, because I was once flamed for removing the man-files which I believe are also not required. And (hint, hint @bgoodri ) I thought that these would have been put into gitignore if they were not required, but gitignore is almost empty. And .Rbuildignore?

D

When I switched to rstantools 2.0.0, this is what I added to .Rbuildignore:

rcppExports.cpp
stanExports_*

and to .gitignore:

*.cc
*.cpp
*.h
1 Like

Should we just have rstantools automatically add these to .Rbuildignore (and .gitignore if it exists)? I don’t think automating it would cause any problems anywhere. I can definitely do this when I have a chance, or if you (@mcol) or anyone else has time and wants to make a PR for this that would be great too.

Yeah

Ok I opened an issue for this https://github.com/stan-dev/rstantools/issues/65. I will definitely add this before the next release if nobody has added it before then.

Hi everyone,

How can I make that rstantools generates the makevars.xxx automathic? I lost that rstantools actualization.

Greetings.

The rstantools package does not affect the Makevars or Makevars.win files in the user’s home directory. It only writes the src/Makevars and src/Makevars.win files for the package in question. To do the former, see

1 Like

And one more question even so I have to change .R makevars file to make my own package work on windows, what would be the best way to send my package to cran?

Do STAN have some regulations recommendations? Other than the normal ones in the rstantools recomendations

The rstantools::rstan_create_package will create packages that compile on CRAN. You can upload them to https://win-builder.r-project.org/ to verify. It is only for developing packages that you have to worry about ~/.R/Makevars.win .

1 Like

Ok, that is good to know so If my package is in cran I won’t have to change my ~/.R/Makevars.win, ? Cause my looks totally different than the one on:

You need a ~/.R/Makevars.win like that on the wiki page in order to install your package from source on Windows locally. CRAN is already configured to build a binary version of your package for Windows. The overwhelming majority of R users on Windows install the binary version of the package on CRAN. Occassionally you will encounter someone who wants to install your package from source on Windows and they too will need a ~/.R/Makevars.win like that on the wiki page to do so. This post will become inapplicable with R 4.0.

Mine looks like this:

CXX14FLAGS=-O3 -march=native -mtune=native
CXX11FLAGS=-O3 -march=native -mtune=native
CXX11FLAGS=-O3 -mtune=native CXX14 = $(BINPREF)g++ -m$(WIN) -std=c++1y
CXX14 = g++ -std=c++1y
CXX14FLAGS = -O3 -Wno-unused-variable -Wno-unused-function

And for make it like this i use this function:

    dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
M <- file.path(dotR, ifelse(.Platform$OS.type == "windows", "Makevars.win", "Makevars"))
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS=-O3 -march=native -mtune=native",
    if( grepl("^darwin", R.version$os)) "CXX14FLAGS += -arch x86_64 -ftemplate-depth-256" else
      if (.Platform$OS.type == "windows") "CXX11FLAGS=-O3 -march=native -mtune=native" else
        "CXX14FLAGS += -fPIC","CXX11FLAGS=-O3 -mtune=native CXX14 = $(BINPREF)g++ -m$(WIN) -std=c++1y",
    "CXX14 = g++ -std=c++1y","CXX14FLAGS = -O3 -Wno-unused-variable -Wno-unused-function",
    file = M, sep = "\n", append = TRUE)

But as you can see is totally different from the wiki one

But that is the only way I could run and compile my package, and to make others install it from my github

Yes, installing from GitHub is essentially the same as installing from source via CRAN, which is why most people on Windows use binary packages provided by CRAN.

Thanks I really need to get better on this