Compilation error - Windows 10

Hi,

I’m probably facing a compilation problem. This problem started suddenly, using brms: in the same R session brms start to fail to compile, with the error below.
I tried to reinstall both brms and Rstan alone and the same problem persisted.
I looked for similar problems in other topics but I couldn’t find anything to help with the case.

Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! file2e341bd05be1.cpp:6:36: warning: ISO C99 requires whitespace after the macro name
 #define STAN__SERVICES__COMMAND_HPP#include <boost/integer/integer_log2.hpp>
                                    ^
file2e341bd05be1.cpp:33:40: error: expected template-name before '<' token
   : public stan::model::model_base_crtp<model2e34283def9_schools> {
                                        ^
file2e341bd05be1.cpp:33:40: error: expected '{' before '<' token
file2e341bd05be1.cpp:33:40: error: expected unqualified-id before '<' token
file2e341bd05be1.cpp:546:1: error: expected '}' at end of input
 }
 ^
make: *** [C:/PROGRA~1/R/R-36~1.3/etc/x64/Makeconf:215: file2e341bd05be1.o] Error 1
Além disso: Warning message:
In system(cmd, intern = !verbose) :
  execução do comando 'C:/PROGRA~1/R/R-36~1.3/bin/x64/R CMD SHLIB file2e341bd05be1.cpp 2> file2e341bd05be1.cpp.err.txt' teve status 1
Error in sink(type = "output") : conexão inválida

I would appreciate it if someone helped me with this.

Thanks!

OS: Windows 10
R version 3.6.3
brms version 2.13.0

Where did you install rstan from?

I reinstalled Rstan from the instructions explained in: [https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started.]
I used to use only brms, which were working normally. Then suddenly these error messages started when compiling. In the attempt to debug I removed both brms and Rstan, and reinstalled first Rstan (with the same followed error) and then brms.

From binary or from source?

From binary. I just also reinstalled Rtools (3.5), and followed the steps to reinstall Rstan, but the error message remains the same.

packageVersion("rstan") says 2.19.3?

Yes

I don’t know how that is happening, but just install tomorrow’s version of rstan:

install.packages(
"https://win-builder.r-project.org/KR31xCf9CKEp/rstan_2.21.1.zip", 
repos = NULL, type = "win.binary")

It has been successfully installed.
When loading rstan, there were a error with RcppParallel version (5.0.0 - it needs 5.0.1). Updated package, and in a new R session I tried load Rstan. A window pop-up with this message:

The EXTPTR_PTR procedure entry point could not be found in the dynamic link library C:\Program\Files\R\R-3.6.3\library\rstan\libs\x64\rstan.dll (my translation)

In R, the following error message:

Error: package or namespace load failed for ‘rstan’ in inDL(x, as.logical(local), as.logical(now), …):
unable to load shared object ‘C:/Program Files/R/R-3.6.3/library/rstan/libs/x64/rstan.dll’:
LoadLibrary failure: The specified procedure could not be found. (my translation)
In addition: Warning message:
package ‘rstan’ was built under R version 4.1.0

Thank in advance for all the help!

Sorry, forgot you were using the old version of R. Try this one

install.packages(
"https://win-builder.r-project.org/57bAMmygvC2m/rstan_2.21.1.zip",
repos = NULL, type = "win.binary")

I have Installed the new source version, which started to show another error (similar with the one explained in [Trouble finding Eigen.hpp]).
I Tried to downgrade StanHeaders to 2.19.0, but the error remained. As explained there, tried also to install R in a folder whitout a blank space in the name (directly in C), but it doesn’t change a thing.

The NEXT version of Stan will not be able to pre-process your Stan program.
Please open an issue at
Issues · stan-dev/stanc3 · GitHub
if you can share or at least describe your Stan program. This will help ensure that Stan
continues to work on your Stan programs in the future. Thank you!
This message can be avoided by wrapping your function call inside suppressMessages().
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! cc1plus.exe: fatal error: C:C:/R-3.6.3/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: Invalid argument
compilation terminated.
make: *** [C:/R-36~1.3/etc/x64/Makeconf:215: filefb4615366a3.o] Error 1
Além disso: Warning messages:
1: In file.remove(c(unprocessed, processed)) :
não foi possível remover o arquivo ‘C:\Users\ADMINI~1\AppData\Local\Temp\RtmpKsDyWo\filefb47b836bf4.stan’, motivo ‘No such file or directory’
2: In system(cmd, intern = !verbose) :
execução do comando ‘C:/R-3.6.3/bin/x64/R CMD SHLIB filefb4615366a3.cpp 2> filefb4615366a3.cpp.err.txt’ teve status 1
Error in sink(type = “output”) : conexão inválida

After removing Rtools35 and R 3.6.0, and after installing Rtools40 and R 4.0, in a new path library, Rstan an brms back to compile normally.