在Cygwin下的Windows中构建R包

时间:2017-06-10 16:46:45

标签: r cygwin

当尝试在Cygwin下的Win10上从源代码更新R包dplyr到0.7.0时(dplyr 0.7.0的windows二进制文件不可用。另外我的R安装不在Cygwin和我的R安装下来自二进制)。但是当我跑步时

R CMD INSTALL dplyr_0.7.0.tar.gz

请参阅以下错误:

* installing to library 'C:/Program Files/R/R-3.4.0/library'
* installing *source* package 'dplyr' ...
** package 'dplyr' successfully unpacked and MD5 sums checked
** libs
c:/Rtools/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-34~1.0/include" -DNDEBUG    -I../inst/include -DCOMPILING_DPLYR -DRCPP_USING_UTF8_ERROR_STRING -I"C:/Program Files/R/R-3.4.0/library/Rcpp/include" -I"C:/Program Files/R/R-3.4.0/library/BH/include" -I"C:/Program Files/R/R-3.4.0/library/bindrcpp/include" -I"C:/Program Files/R/R-3.4.0/library/plogr/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c   RcppExports.cpp -o RcppExports.o
/bin/sh: c:/Rtools/mingw_64/bin/g++: No such file or directory
make: *** [C:/PROGRA~1/R/R-34~1.0/etc/x64/Makeconf:215: RcppExports.o]    Error 127
Warning: running command 'make -f "Makevars.win" -f "C:/PROGRA~1/R/R -34~1.0/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-34~1.0/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="dplyr.dll" WIN=64 TCLBIN=64 OBJECTS="RcppExports.o address.o api.o arrange.o between.o bind.o combine_variables.o distinct.o filter.o group_by.o group_indices.o hybrid.o hybrid_count.o hybrid_debug.o hybrid_in.o hybrid_minmax.o hybrid_nth.o hybrid_offset.o hybrid_simple.o hybrid_window.o init.o init_register.o join.o join_exports.o mutate.o rlang-export.o select.o set.o slice.o summarise.o test.o utils.o window.o"' had status 2
ERROR: compilation failed for package 'dplyr'
* removing 'C:/Program Files/R/R-3.4.0/library/dplyr'
* restoring previous 'C:/Program Files/R/R-3.4.0/library/dplyr'

错误原因是R(使用Rtools库)在c:/ Rtools / mingw_64 / bin /下查找g ++ / gcc编译器,而不是在Cygwin / usr / bin /

有没有办法改变R CMD INSTALL的默认行为,这样可以在没有Rtoools的Windows中从源代码构建R包?

由于

PS。我想这篇文章 how do you use cygwin to compile an R package from source? 是相关的,但似乎R安装在Cygwin下,这不是我的情况。

PPS。看来我需要更改

下定义的变量
R CMD config

任何想法如何?

1 个答案:

答案 0 :(得分:0)

我不确定最佳解决方案是什么。但你可以通过修改$(R_HOME)/etc/x64/Makeconf中的BINPREF来解决这个问题。 c:/Rtools/mingw_64/bin/是默认值。

PS:你几乎可以肯定可以使用cygwin编译器构建R包,只要涉及C链接。我在Visual Studio下构建了一些我的。