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

Hi,
I am new to Stan, after I install Stan and run function stan, I got the error message as following:

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! g++.exe: error: MSOPROD/syin/Documents/R-3.6.3/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directory
g++.exe: error: MSOPROD/syin/Documents/R-3.6.3/library/StanHeaders/include: No such file or directory
g++.exe: error: MSOPROD/syin/Documents/R-3.6.3/library/RcppEigen/include: No such file or directory
make: *** [D:/ONEDRI~1/syin/DOCUME~1/R-36~1.3/etc/x64/Makeconf:215: file58344932393b.o] Error 1
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘D:/ONEDRI~1/syin/DOCUME~1/R-36~1.3/bin/x64/R CMD SHLIB file58344932393b.cpp 2> file58344932393b.cpp.err.txt’ had status 1
Error in sink(type = “output”) : invalid connection

Before that I already test Rtools as following

pkgbuild::has_build_tools(debug = TRUE)
[1] TRUE

Is there anyone who know how to resolve this problem. Thank you very much for your help.

what is your operating system?
which Stan interface, which version are you using - RStan?

Can you try the instructions in this post:

Hi Mitzi,

Hi Andrew,

When I run install.packages( "https://win-builder.r-project.org/9256KcZ01L9C/StanHeaders_2.19.2.zip ", repos = NULL, type = “win.binary”), I got the error
as following:

Try

which has a fixed link to the StanHeaders package.

Hi,

I’m also new to stan, and having similar compilation errors in RStudio/Windows 10. I’ve tried following the advice in this thread, as well as other related ones: uninstalling and re-installing the rstan and StanHeaders packages. But errors like these keep popping up:

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! g++.exe: error: Files/Documents/R/win-library/3.5/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directory
g++.exe: error: Files/Documents/R/win-library/3.5/StanHeaders/include: No such file or directory
g++.exe: error: Files/Documents/R/win-library/3.5/RcppEigen/include: No such file or directory
make: *** [C:/PROGRA~1/R/R-35~1.3/etc/x64/Makeconf:215: file3420351217da.o] Error 1
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘C:/PROGRA~1/R/R-35~1.3/bin/x64/R CMD SHLIB file3420351217da.cpp 2> file3420351217da.cpp.err.txt’ had status 1
Error in sink(type = “output”) : invalid connection

I also note that, in attempting to run my code, I get a popup window that tells me I need to install rtools, even though I have the latest version installed. Any assistance you can provide is greatly appreciated.

Hi,

I resolved this issue by reinstall R under a new directory to make sure there is no space included in the directory path. My previous directory includes space and after I reinstall R under a new directory without space then it works. Hope it helps.

Shuxin

2 Likes

I think that solved it. Thank you!

1 Like