尝试使用 Rtools 3.5/Rv3.5.1 编译 rstan 时出现 make*** 错误 126

问题描述

我在 Windows 10 上使用 R v.3.5.1、R studio v 1.3.1093 和 Rtools 3.5。

我知道已经成功安装了R工具并找到了工具链,已经关注https://github.com/stan-dev/rstan/wiki/Configuring-C---Toolchain-for-Windows并成功安装:

install.packages("jsonlite",type="source").

但是,当我尝试使用

从源代码安装rstan时
pkgbuild::with_build_tools(install.packages("rstan",type = "source"))

我收到以下错误消息:

sh: C:/Rtools/mingw_32/bin/: Is a directory
make: *** [C:/PROGRA~1/R/R-35~1.1/etc/i386/Makeconf:215: sparse_extractors.o] Error 126
ERROR: compilation Failed for package 'rstan'
* removing 'C:/R/library/rstan'
In R CMD INSTALL
Warning in install.packages :
  installation of package ‘rstan’ had non-zero exit status

目前,我的 makevars.win 文件包含以下内容

CXX14 = C:/Rtools/mingw_$(WIN)/bin/ g++ -std=c++1y
CXX14FLAGS = -O3 -Wno-unused-variable -Wno-unused-function

尽管我在 makevars 文件中尝试了各种不同的行,但仍然出现上述错误 126 消息。

我可以成功安装 rstan/rstanarm/brms 等的二进制版本。但是当我尝试编译模型时它失败了。当我尝试这样做并意识到二进制版本不起作用时,我在尝试安装源版本之前卸载了 rstan/rstanarm 和 brms。

如果您能帮助修复此错误并成功安装 rstan,我们将不胜感激!

解决方法

在 g++ 之前有一个空格会导致 Makefile 执行目录(由于它不是可执行文件而失败)。

删除空格。