Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created!

Hi,
I am new to rstan. The installation was successfully done within Windows10, in C:
However, when I try to run the first model after the installation instructions, I get the following error message:

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! file27b46fc111f7.cpp:8:39: fatal error: stan/model/model_header.hpp: No such file or directory
#include <stan/model/model_header.hpp>
^
compilation terminated.
make: *** [C:/PROGRA~1/R/R-36~1.2/etc/x64/Makeconf:215: file27b46fc111f7.o] Error 1
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘C:/PROGRA~1/R/R-36~1.2/bin/x64/R CMD SHLIB file27b46fc111f7.cpp 2> file27b46fc111f7.cpp.err.txt’ had status 1
Error in sink(type = “output”) : invalid connection

I had a look at the other similar posts, (re-installation, installing in C:) but they have not worked for me. Any advise would be most appreciated.

Thank you.

It probably installed StanHeaders to some directory that it cannot find. What is

system.file("include", "src", "stan", "model", "model_header.hpp",
            package = "StanHeaders")

?

Thank you for your response.

system.file(“include”, “src”, “stan”, “model”, “model_header.hpp”, package = “StanHeaders”)
[1] “\\Jericho/home/petros.boutselis/Documents/R/win-library/3.6/StanHeaders/include/src/stan/model/model_header.hpp”

Yeah, having it in a networked drive is tricky. When you do

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

what is the compilation argument, i.e. the line in the middle of the output that starts with g++?

The output is:
Compilation argument:
C:/PROGRA~1/R/R-36~1.2/bin/x64/R CMD SHLIB file27b442af3432.cpp 2> file27b442af3432.cpp.err.txt
C:/Rtools/mingw_64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -I"\Jericho/home/petros.boutselis/Documents/R/win-library/3.6/Rcpp/include/" -I"\Jericho/home/petros.boutselis/Documents/R/win-library/3.6/RcppEigen/include/" -I"\Jericho/home/petros.boutselis/Documents/R/win-library/3.6/RcppEigen/include/unsupported" -I"\Jericho/home/petros.boutselis/Documents/R/win-library/3.6/BH/include" -I"\Jericho/home/petros.boutselis/Documents/R/win-library/3.6/StanHeaders/include/src/" -I"\Jericho/home/petros.boutselis/Documents/R/win-library/3.6/StanHeaders/include/" -I"\Jericho/home/petros.boutselis/Documents/R/win-library/3.6/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -std=c++1y -march=core2 -O2 -Wall -mtune=generic -c file27b442af3432.cpp -o file27b442af3432.o
file27b442af3432.cpp:8:39: fatal error: stan/model/model_header.hpp: No such file or directory
#include <stan/model/model_header.hpp>
^
compilation terminated.
make: *** [C:/PROGRA~1/R/R-36~1.2/etc/x64/Makeconf:215: file27b442af3432.o] Error 1

ERROR(s) during compilation: source code errors or compiler configuration errors!

Hi,
Sorry for coming back, but I wanted to make sure that I have provide you with the right output?
Thank you again for your time.

That is the right output, but I think it does not know what to do with paths that start with \Jericho. Does

example(cxxfunction, package = "inline", run.dontrun = TRUE)
work?

Unfortunately not:

example(cxxfunction, package = “inline”, run.dontrun = TRUE)

cxxfnc> # default plugin
cxxfnc> fx <- cxxfunction( signature(x = “integer”, y = “numeric” ) , ’
cxxfnc+ return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
cxxfnc+ ’ )

cxxfnc> fx( 2L, 5 )
[1] 10

cxxfnc> # Rcpp plugin
cxxfnc> if( require( Rcpp ) ){
cxxfnc+
cxxfnc+ fx <- cxxfunction( signature(x = “integer”, y = “numeric” ) , ’
cxxfnc+ return wrap( as(x) * as(y) ) ;
cxxfnc+ ', plugin = “Rcpp” )
cxxfnc+ fx( 2L, 5 )
cxxfnc+
cxxfnc+ ## equivalent shorter form using rcpp()
cxxfnc+ fx <- rcpp(signature(x = “integer”, y = “numeric”),
cxxfnc+ ’ return wrap( as(x) * as(y) ) ; ')
cxxfnc+
cxxfnc+ }
Loading required package: Rcpp

Attaching package: ‘Rcpp’

The following object is masked from ‘package:inline’:

registerPlugin

file26cc77defd9.cpp:4:18: fatal error: Rcpp.h: No such file or directory
#include <Rcpp.h>
^
compilation terminated.
make: *** [C:/PROGRA~1/R/R-36~1.2/etc/x64/Makeconf:215: file26cc77defd9.o] Error 1

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source:
1:
2: // includes from the plugin
3:
4: #include <Rcpp.h>
5:
6:
7: #ifndef BEGIN_RCPP
8: #define BEGIN_RCPP
9: #endif
10:
11: #ifndef END_RCPP
12: #define END_RCPP
13: #endif
14:
15: using namespace Rcpp;
16:
17: // user includes
18:
19:
20: // declarations
21: extern “C” {
22: SEXP file26cc77defd9( SEXP x, SEXP y) ;
23: }
24:
25: // definition
26:
27: SEXP file26cc77defd9( SEXP x, SEXP y ){
28: BEGIN_RCPP
29:
30: return wrap( as(x) * as(y) ) ;
31:
32: END_RCPP
33: }
34:
35:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! file26cc77defd9.cpp:4:18: fatal error: Rcpp.h: No such file or directory
#include <Rcpp.h>
^
compilation terminated.
make: *** [C:/PROGRA~1/R/R-36~1.2/etc/x64/Makeconf:215: file26cc77defd9.o] Error 1
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘C:/PROGRA~1/R/R-36~1.2/bin/x64/R CMD SHLIB file26cc77defd9.cpp 2> file26cc77defd9.cpp.err.txt’ had status 1

Both of these error messages are saying it cannot find files that are in packages that are installed in your home directory. I think you need to figure out a way to install packages somewhere in C:/. Or maybe map the network drive your home directory is on to some place in C:/ or at least that has the same conventions for specifying paths.

Thank you very much for the advice.