Error on the stan file compilation using R 3.6.0. and Win 10

喜夏-厌秋 提交于 2020-01-16 18:52:51

问题


Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! Error in .shlib_internal(commandArgs(TRUE)) : 
  C++14 standard requested but CXX14 is not defined
Calls: <Anonymous> -> .shlib_internal
Execution halted
In addition: Warning message:
In system(cmd, intern = !verbose) :
  running command 'C:/PROGRA~1/R/R-36~1.0/bin/x64/R CMD SHLIB file1a1860a0379.cpp 2> file1a1860a0379.cpp.err.txt' had status 1
Error in sink(type = "output") : invalid connection

Some non-English page said that we can overcome by executing the following R script, but it did not work in my case:

dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) 
  dir.create(dotR)
M <- file.path(dotR, "Makevars")
if (!file.exists(M)) 
  file.create(M)
cat("\nCXX14FLAGS=-O3 -Wno-unused-variable -Wno-unused-function",
    "CXX14 = g++ -std=c++1y",
    file = M, sep = "\n", append = TRUE)

The above R script is same as in the following page:

https://github.com/stan-dev/rstan/issues/569


I tried to uninstall and install according to the following page, but the above error occurred.

Rstan installation: https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started

REF; https://github.com/stan-dev/stan/issues/1613

ref: https://github.com/stan-dev/rstan/issues/633


回答1:


For me, the issue has been solved by adding manually the following line into the file .R/Makevars.win.

CXX14 = "C:\Rtools\mingw_64\bin\g++.exe"


来源:https://stackoverflow.com/questions/56256884/error-on-the-stan-file-compilation-using-r-3-6-0-and-win-10

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!