R CMD check fails after adding Stan infrastructure to an existing R package

Thanks Andrew,

It looks like you were referring to the contents of the Makevars.win file. I searched more on the forum, since people have been facing similar issues before. I’m taking a step back to summarize the setting, with the hope to provide more information and help resolve this:

  1. Output from running Sys.getenv("PATH") in the console:
[1] "C:\\Program Files\\R\\R-3.6.0\\bin\\x64;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;c:\\Program Files (x86)\\ATI Technologies\\ATI.ACE\\Core-Static;C:\\Program Files (x86)\\Bitvise SSH Client;C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64\\;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\Git\\cmd;C:\\Users\\lbour\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\lbour\\AppData\\Local\\GitHubDesktop\\bin;%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps;"
  1. The contents of the .Renviron file are:
PATH="C:/RBuildTools/3.5/bin;${PATH}"
  1. The contents of the .Rprofile file:
Sys.setenv(BINPREF = "C:/RBuildTools/3.5/mingw_$(WIN)/bin/")

Having checked that, I proceed with the following.

Option 1
4. I modify my Makevars file to:

CXX11 = "C:/RBuildTools/3.5/mingw_64/bin/g++.exe" -std=c++11
CXX11FLAGS = -O3 -Wno-unused-variable -Wno-unused-function

CXX14 = "C:/RBuildTools/3.5/mingw_64/bin/g++.exe" -std=c++1y
CXX14FLAGS = -O3 -Wno-unused-variable -Wno-unused-function

Note that I explicitly used -std=c++11 for CXX11, following the error message above.

  1. I have modified my Makevars.win file to:
CXX11 = "C:/RBuildTools/3.5/mingw_64/bin/g++.exe" -std=c++11
CXX14 = "C:/RBuildTools/3.5/mingw_64/bin/g++.exe" -std=c++1y
CXX14FLAGS=-O3 -march=native -mtune=native
CXX11FLAGS=-O3 -march=native -mtune=native
  1. pkgbuild::compile_dll() is executed successfully in the console.

  2. I restart R and then attempt Clean and Rebuild. Same errors apply, see attached screenshots:

[the very first error]

[snippet of errors appearing later]

Option 2
Leave Makevars as above, then modify Makevars.win file to:

CXX14=$(BINPREF)g++ -O2 -march=native -mtune=native
CXX14FLAGS=-O3 -march=native -mtune=native
CXX11FLAGS=-O3 -march=native -mtune=native

following this answer.

Same errors apply.